summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-10-16 13:26:47 +0900
committernagachika <nagachika@ruby-lang.org>2021-10-16 13:26:47 +0900
commita2fe4b75e4b236ad15778c59ace63006ace53889 (patch)
treeea38d78594489d61792d8439fcdd9855a42c0ed3 /test
parentcfad0583eb18bb4505f28ee5cfab703a6b9987be (diff)
merge revision(s) 217df51f0e5d9824ed712a4d175f555d932e44d8: [Backport #18232]
Dump outer variables tables when dumping an iseq to binary This commit dumps the outer variables table when dumping an iseq to binary. This fixes a case where Ractors aren't able to tell what outer variables belong to a lambda after the lambda is loaded via ISeq.load_from_binary [Bug #18232] [ruby-core:105504] --- compile.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- test/ruby/test_iseq.rb | 10 +++++++++ 2 files changed, 64 insertions(+), 1 deletion(-)
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_iseq.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index e3ca1ba926..08340c662c 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -82,6 +82,16 @@ class TestISeq < Test::Unit::TestCase
end;
end if defined?(RubyVM::InstructionSequence.load)
+ def test_lambda_with_ractor_roundtrip
+ iseq = compile(<<~EOF)
+ x = 42
+ y = lambda { x }
+ Ractor.make_shareable(y)
+ y.call
+ EOF
+ assert_equal(42, ISeq.load_from_binary(iseq.to_binary).eval)
+ end
+
def test_disasm_encoding
src = "\u{3042} = 1; \u{3042}; \u{3043}"
asm = compile(src).disasm