Project

General

Profile

Actions

Bug #22647

closed

`argument stack underflow (-1)` Compiling `redo` Inside `for` Loop Target Index Expression

Bug #22647: `argument stack underflow (-1)` Compiling `redo` Inside `for` Loop Target Index Expression

Added by steviejj (Steven Johnstone) 2 days ago. Updated about 7 hours ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
ruby 4.1.0dev (2026-11-26T13:52:03Z HEAD 17eecca74a) +PRISM [aarch64-linux]
[ruby-core:127738]

Description

for obj[(redo if done)] in ary
  work
end
ruby --parser=parse.y -e 'RubyVM::InstructionSequence.compile("for obj[(redo if done)] in ary; work; end"); puts :ok'
ruby --parser=prism   -e 'RubyVM::InstructionSequence.compile("for obj[(redo if done)] in ary; work; end"); puts :ok'

Under --parser=parse.y:

ok

Under --parser=prism:

-- raw disasm--------
   0000 putself                                                          (   1)
   0001 opt_send_without_block <calldata:obj, 0>                         (   1)
   trace: 1
   0003 putself                                                          (   1)
   0004 opt_send_without_block <calldata:done, 0>                        (   1)
   0006 branchunless         <L009>                                      (   1)
 <L016> [sp: 1, unremovable: 1, refcnt: 1]
   adjust: [label: 0]
*  0008 jump                 <L000>                                      (   1)
   adjust: [label: 16]
   0010 putnil                                                           (   1)
   0011 jump                 <L017>                                      (   1)
 <L009> [sp: 1, unremovable: 0, refcnt: 1]
   0013 putnil                                                           (   1)
 <L017> [sp: -1, unremovable: 0, refcnt: 1]
   0014 getlocal_WC_0        3                                           (   1)
   0016 expandarray          1, 0                                        (   1)
   0019 topn                 2                                           (   1)
   0021 topn                 2                                           (   1)
   0023 topn                 2                                           (   1)
   0025 opt_aset             <calldata:[]=, 2>                           (   1)
   0027 pop                                                              (   1)
   0028 pop                                                              (   1)
   0029 pop                                                              (   1)
   0030 pop                                                              (   1)
   trace: 100
   0031 nop                                                              (   1)
 <L000> [sp: -1, unremovable: 1, refcnt: 5]
   0032 putself                                                          (   1)
   0033 opt_send_without_block <calldata:work, 0>                        (   1)
 <L001> [sp: -1, unremovable: 0, refcnt: 3]
   trace: 200
   0035 leave                                                            (   1)
---------------------
<compiled>: <compiled>:1: argument stack underflow (-1) (SyntaxError)

Updated by kddnewton (Kevin Newton) 1 day ago Actions #1

  • Assignee set to prism

Updated by kddnewton (Kevin Newton) about 7 hours ago Actions #2

  • Status changed from Open to Closed

Applied in changeset git|b557a36bddb56f58d0b54cb205c027465b283573.


[PRISM] Properly compile jumps in for index

[Bug #22647]

Actions

Also available in: PDF Atom