From cfa15bb173723b8bb6110a81241bcdffa18193fb Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 22 Jan 2024 16:03:58 -0800 Subject: Handle trailing commas on blocks We need to set a special flag on block iseqs when there is a trailing comma. Fixes: https://github.com/ruby/prism/issues/2244 --- test/ruby/test_compile_prism.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 328074fc52..10def69ff2 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1515,6 +1515,10 @@ a CODE end + def test_trailing_comma_on_block + assert_prism_eval("def self.m; yield [:ok]; end; m {|v0,| v0 }") + end + def test_complex_default_params assert_prism_eval("def self.foo(a:, b: '2'.to_i); [a, b]; end; foo(a: 1)") assert_prism_eval("def self.foo(a:, b: 2, c: '3'.to_i); [a, b, c]; end; foo(a: 1)") -- cgit v1.2.3