summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-13 14:25:34 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-11-07 12:40:27 +0900
commit334b69e5042f47f89c8780c1d7efa32d70c84786 (patch)
tree6dccdd52ebecbb569c969c6fd4aacd595c4e1ded /test/ruby
parent66b0847602ffa47575371f4d5a9a04dc6013ba49 (diff)
rb_id_serial_to_id: return unregistered ID as an internal ID
```ruby def foo(*); ->{ super }; end ``` This code makes anonymous parameters which is not registered as an ID. The problem is that when Ractors try to scan `getlocal` instructions, it puts the Symbol corresponding to the parameter in to a hash. Since it is not registered, we end up with a strange exception. This commit wraps the unregistered ID in an internal ID so that we get the same exception for `...` as `*`. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: John Hawthorn <john@hawthorn.email>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5035
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_iseq.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 3a02c182aa..19357a774d 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -95,6 +95,26 @@ class TestISeq < Test::Unit::TestCase
assert_equal(42, ISeq.load_from_binary(iseq.to_binary).eval)
end
+ def test_super_with_block
+ iseq = compile(<<~EOF)
+ def touch(*) # :nodoc:
+ foo { super }
+ end
+ 42
+ EOF
+ assert_equal(42, ISeq.load_from_binary(iseq.to_binary).eval)
+ end
+
+ def test_super_with_block_and_kwrest
+ iseq = compile(<<~EOF)
+ def touch(**) # :nodoc:
+ foo { super }
+ end
+ 42
+ EOF
+ assert_equal(42, ISeq.load_from_binary(iseq.to_binary).eval)
+ end
+
def test_lambda_with_ractor_roundtrip
iseq = compile(<<~EOF)
x = 42
@@ -340,6 +360,14 @@ class TestISeq < Test::Unit::TestCase
end
end
+ def anon_star(*); end
+
+ def test_anon_param_in_disasm
+ iseq = RubyVM::InstructionSequence.of(method(:anon_star))
+ param_names = iseq.to_a[iseq.to_a.index(:method) + 1]
+ assert_equal [2], param_names
+ end
+
def strip_lineno(source)
source.gsub(/^.*?: /, "")
end