From: "steviejj (Steven Johnstone) via ruby-core" Date: 2026-11-26T16:49:50+00:00 Subject: [ruby-core:127738] [Ruby Bug#22647] `argument stack underflow (-1)` Compiling `redo` Inside `for` Loop Target Index Expression Issue #22647 has been reported by steviejj (Steven Johnstone). ---------------------------------------- Bug #22647: `argument stack underflow (-1)` Compiling `redo` Inside `for` Loop Target Index Expression https://bugs.ruby-lang.org/issues/22647 * Author: steviejj (Steven Johnstone) * Status: Open * ruby -v: ruby 4.1.0dev (2026-11-26T13:52:03Z HEAD 17eecca74a) +PRISM [aarch64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```ruby for obj[(redo if done)] in ary work end ``` ```bash 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`: ```text ok ``` Under `--parser=prism`: ```text -- raw disasm-------- 0000 putself ( 1) 0001 opt_send_without_block ( 1) trace: 1 0003 putself ( 1) 0004 opt_send_without_block ( 1) 0006 branchunless ( 1) [sp: 1, unremovable: 1, refcnt: 1] adjust: [label: 0] * 0008 jump ( 1) adjust: [label: 16] 0010 putnil ( 1) 0011 jump ( 1) [sp: 1, unremovable: 0, refcnt: 1] 0013 putnil ( 1) [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 ( 1) 0027 pop ( 1) 0028 pop ( 1) 0029 pop ( 1) 0030 pop ( 1) trace: 100 0031 nop ( 1) [sp: -1, unremovable: 1, refcnt: 5] 0032 putself ( 1) 0033 opt_send_without_block ( 1) [sp: -1, unremovable: 0, refcnt: 3] trace: 200 0035 leave ( 1) --------------------- : :1: argument stack underflow (-1) (SyntaxError) ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/