Actions
Bug #19862
closedargument stack underflow compile error happens for the combination of and/or & one line pattern matching
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0dev (2023-09-04T18:01:33Z master db3b814cb0) [arm64-darwin21]
Description
This code raises argument stack underflow compile error on ruby 3.3 which is under development.
# test3.rb
if true or {a: 0} in {a:}
p 1
else
p 0
end
% ruby -v test3.rb
ruby 3.3.0preview1 (2023-05-12 master a1b01e7701) [arm64-darwin21]
test3.rb:2: warning: assigned but unused variable - a
-- raw disasm--------
trace: 1
0000 jump <L000> ( 2)
<L006> [sp: 0]
<L004> [sp: 0]
* 0002 pop ( 2)
0003 pop ( 2)
0004 jump <L001> ( 2)
<L000> [sp: 0]
trace: 1
0006 putself ( 3)
0007 putobject_INT2FIX_1_ ( 3)
0008 opt_send_without_block <calldata:p, 1> ( 3)
0010 leave ( 5)
<L001> [sp: -1]
trace: 1
0011 putself ( 5)
0012 putobject_INT2FIX_0_ ( 5)
0013 opt_send_without_block <calldata:p, 1> ( 5)
0015 leave ( 5)
---------------------
test3.rb:2: argument stack underflow (-1)
test3.rb: compile error (SyntaxError)
% ./ruby -v ../../test3.rb
ruby 3.3.0dev (2023-09-04T18:01:33Z master db3b814cb0) [arm64-darwin21]
`RubyGems' were not loaded.
`error_highlight' was not loaded.
`did_you_mean' was not loaded.
`syntax_suggest' was not loaded.
../../test3.rb:2: warning: assigned but unused variable - a
-- raw disasm--------
trace: 1
0000 jump <L000> ( 2)
<L006> [sp: 0]
<L004> [sp: 0]
* 0002 pop ( 2)
0003 pop ( 2)
0004 jump <L001> ( 2)
<L000> [sp: 0]
trace: 1
0006 putself ( 3)
0007 putobject_INT2FIX_1_ ( 3)
0008 opt_send_without_block <calldata:p, 1> ( 3)
0010 leave ( 5)
<L001> [sp: -1]
trace: 1
0011 putself ( 5)
0012 putobject_INT2FIX_0_ ( 5)
0013 opt_send_without_block <calldata:p, 1> ( 5)
0015 leave ( 5)
---------------------
../../test3.rb:2: argument stack underflow (-1)
../../test3.rb: compile error (SyntaxError)
This also raises same error.
# test4.rb
if false and {a: 0} in {a:}
p 1
else
p 0
end
As far as I checked, 3.0.0, 3.1.0, 3.2.0 don't raise the error.
Updated by nobu (Nobuyoshi Nakada) about 1 year ago
- Related to Bug #17534: Pattern-matching is broken with find pattern added
Updated by nobu (Nobuyoshi Nakada) about 1 year ago
Updated by nobu (Nobuyoshi Nakada) about 1 year ago
- Status changed from Open to Closed
Applied in changeset git|6e64d4370456190541705ec4c6cf3af6bf4ac647.
[Bug #19862] Skip compiled result of never reachable expression
Actions
Like0
Like0Like0Like0