summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-01-24 11:45:53 -0500
committerPeter Zhu <peter@peterzhu.ca>2024-01-24 13:42:21 -0500
commitdc8fb7d97ff0113c738bded825a37b3196eeaaae (patch)
treef9de24a232c7f24d3228e5268cb4ce7d2fa8c4da /test/ruby
parent455fb320384a597bc195adcee6bc1071fc64a245 (diff)
[PRISM] Fix crash in anonymous block with forwarding arguments
Fixes ruby/prism#2262.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_compile_prism.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index bcbd5449e0..b7aa75a5b0 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -1725,7 +1725,7 @@ end
def test_BlockArgumentNode
assert_prism_eval("1.then(&:to_s)")
- # Test forwarding with no name
+ # Test anonymous block forwarding
assert_prism_eval(<<~RUBY)
o = Object.new
def o.foo(&) = yield
@@ -1733,6 +1733,15 @@ end
o.bar { :ok }
RUBY
+
+ # Test anonymous block forwarding from argument forwarding
+ assert_prism_eval(<<~RUBY)
+ o = Object.new
+ def o.foo = yield
+ def o.bar(...) = foo(&)
+
+ o.bar { :ok }
+ RUBY
end
def test_BlockLocalVariableNode