
Issue #20939 has been updated by ydah (Yudai Takada). Status changed from Open to Closed Thank you. fixed by: https://github.com/ruby/ruby/pull/12338 ---------------------------------------- Bug #20939: When using the parse.y parser, it occurs argument stack underflow (-1) if there is processing after the shareable_constant_value: experimental_everything comment and `C = { **{ k: v } }` https://bugs.ruby-lang.org/issues/20939#change-111199 * Author: ydah (Yudai Takada) * Status: Closed * ruby -v: ruby 3.4.0dev (2024-12-10T03:31:47Z master f12e2622c1) [arm64-darwin23] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- The following code will occurs argument stack underflow if it is a parse.y parser. ```ruby # shareable_constant_value: experimental_everything C = { **{ k: v } } p C ``` The following error message is output. ``` ruby 3.4.0dev (2024-12-06T03:32:20Z master 6ccaa37eb3) [arm64-darwin23] -- raw disasm-------- trace: 1 0000 putspecialobject 1 ( 2) 0002 putobject :k ( 2) 0004 putself ( 2) 0005 opt_send_without_block <calldata:v, 0> ( 2) 0007 newhash 2 ( 2) 0009 newhash 2 ( 2) 0011 opt_send_without_block <calldata:make_shareable, 1> ( 2) 0013 putspecialobject 3 ( 2) * 0015 setconstant :C ( 2) trace: 1 0017 putself ( 3) 0018 opt_getconstant_path [:C] ( 3) 0020 opt_send_without_block <calldata:p, 1> ( 3) 0022 leave ( 3) --------------------- -e:2: argument stack underflow (-1) -e: compile error (SyntaxError) ``` It does not occur in the following cases: ```ruby # shareable_constant_value: experimental_everything C = { **{ k: v } } ``` ```ruby C = { **{ k: v } } p C ``` ```ruby # shareable_constant_value: experimental_everything { **{ k: v } } p C ``` ```ruby # shareable_constant_value: experimental_everything C = { **{ k: 1 } } p C ``` This does not occur in Ruby 3.3: ``` ❯ ruby --parser=parse.y -v -e '# shareable_constant_value: experimental_everything C = { **{ foo: bar } } p C' ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin23] -e:3:in `<main>': undefined local variable or method `bar' for main (NameError) C = { **{ foo: bar } } ^^^ ``` -- https://bugs.ruby-lang.org/