diff options
-rw-r--r-- | test/ruby/test_iseq.rb | 5 | ||||
-rw-r--r-- | vm.c | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 19357a774d..2b3282d5fb 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -135,6 +135,11 @@ class TestISeq < Test::Unit::TestCase assert_raise_with_message(Ractor::IsolationError, /`#{name}'/) do Ractor.make_shareable(y) end + obj = Object.new + def obj.foo(*) ->{super} end + assert_raise_with_message(Ractor::IsolationError, /hidden variable/) do + Ractor.make_shareable(obj.foo) + end end def test_disasm_encoding @@ -1035,9 +1035,14 @@ env_copy(const VALUE *src_ep, VALUE read_only_variables) if (id == src_env->iseq->body->local_table[j]) { VALUE v = src_env->env[j]; if (!rb_ractor_shareable_p(v)) { - rb_raise(rb_eRactorIsolationError, - "can not make shareable Proc because it can refer unshareable object %" - "+" PRIsVALUE " from variable `%" PRIsVALUE "'", v, rb_id2str(id)); + VALUE name = rb_id2str(id); + VALUE msg = rb_sprintf("can not make shareable Proc because it can refer" + " unshareable object %+" PRIsVALUE " from ", v); + if (name) + rb_str_catf(msg, "variable `%" PRIsVALUE "'", name); + else + rb_str_cat_cstr(msg, "a hidden variable"); + rb_exc_raise(rb_exc_new_str(rb_eRactorIsolationError, msg)); } env_body[j] = v; rb_ary_delete_at(read_only_variables, i); |