Actions
Bug #20939
openWhen 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 } }`
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-12-10T03:31:47Z master f12e2622c1) [arm64-darwin23]
Description
The following code will occurs argument stack underflow if it is a parse.y parser.
# 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:
# shareable_constant_value: experimental_everything
C = { **{ k: v } }
C = { **{ k: v } }
p C
# shareable_constant_value: experimental_everything
{ **{ k: v } }
p C
# 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 } }
^^^
Updated by tompng (tomoya ishida) 5 days ago
I think the cause is same as https://bugs.ruby-lang.org/issues/20927
Actions
Like0
Like1