summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2025-05-24 10:02:35 +0200
committerJean Boussier <jean.boussier@gmail.com>2025-06-02 13:41:28 +0200
commitff222ac27afe712ef6ec2bb74c81cdde1a1fa176 (patch)
tree0b9b4579d53e86ca4d8031d77d8a638dda817d66 /test/ruby
parent9a292528305e88fc05c054afcfe25fc23e5c9b80 (diff)
compile.c: Handle anonymous variables in `outer_variable_cmp`
[Bug #21370]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13436
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_iseq.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 8e6087f667..924c144702 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -859,6 +859,25 @@ class TestISeq < Test::Unit::TestCase
end
end
+ def test_serialize_anonymous_outer_variables
+ iseq = RubyVM::InstructionSequence.compile(<<~'RUBY')
+ obj = Object.new
+ def obj.test
+ [1].each do
+ raise "Oops"
+ rescue
+ return it
+ end
+ end
+ obj
+ RUBY
+
+ binary = iseq.to_binary # [Bug # 21370]
+ roundtripped_iseq = RubyVM::InstructionSequence.load_from_binary(binary)
+ object = roundtripped_iseq.eval
+ assert_equal 1, object.test
+ end
+
def test_loading_kwargs_memory_leak
assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~'end;'}", rss: true)
a = iseq_to_binary(RubyVM::InstructionSequence.compile("foo(bar: :baz)"))