diff options
-rw-r--r-- | bootstraptest/test_ractor.rb | 22 | ||||
-rw-r--r-- | vm.c | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 01d02dce77..4da348df67 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -187,6 +187,28 @@ assert_equal '[:ok, :ok, :ok]', %q{ }.map(&:take) } +# Ractor.make_shareable issue for locals in proc [Bug #18023] +assert_equal '[:a, :b, :c, :d, :e]', %q{ + v1, v2, v3, v4, v5 = :a, :b, :c, :d, :e + closure = Proc.new { [v1, v2, v3, v4, v5] } + + Ractor.make_shareable(closure).call +} + +# Ractor.make_shareable issue for locals in proc [Bug #18023] +assert_equal '[:a, :b, :c, :d, :e, :f, :g]', %q{ + a = :a + closure = -> { + b, c, d = :b, :c, :d + -> { + e, f, g = :e, :f, :g + -> { [a, b, c, d, e, f, g] } + }.call + }.call + + Ractor.make_shareable(closure).call +} + ### ### # Ractor still has several memory corruption so skip huge number of tests @@ -1006,7 +1006,7 @@ env_copy(const VALUE *src_ep, VALUE read_only_variables) volatile VALUE prev_env = Qnil; if (read_only_variables) { - for (int i=0; i<RARRAY_LENINT(read_only_variables); i++) { + for (int i=RARRAY_LENINT(read_only_variables)-1; i>=0; i--) { ID id = SYM2ID(rb_str_intern(RARRAY_AREF(read_only_variables, i))); for (unsigned int j=0; j<src_env->iseq->body->local_table_size; j++) { |