From: "kddnewton (Kevin Newton) via ruby-core" Date: 2026-10-16T13:44:02+00:00 Subject: [ruby-core:127140] [Ruby Bug#22450] Jump value attaches block in incorrect place under parse.y Issue #22450 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #22450: Jump value attaches block in incorrect place under parse.y https://bugs.ruby-lang.org/issues/22450 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Sorry about this one. The following code: `check 1, if true then return foo + bar do end end` under Prism: ``` -e: warning: argument of top-level return is ignored == disasm: #@-e:1 (1,0)-(1,49)> 0000 putself ( 1)[Li] 0001 putobject_INT2FIX_1_ 0002 adjuststack 2 0004 putself 0005 opt_send_without_block 0007 putself 0008 send , block in
0011 opt_plus [CcCr] 0013 leave [Re] 0014 putnil 0015 opt_send_without_block 0017 leave == disasm: #@-e:1 (1,39)-(1,45)> 0000 putnil ( 1)[Bc] 0001 leave [Br] ``` but under parse.y: ``` -e: warning: argument of top-level return is ignored == disasm: #@-e:1 (1,0)-(1,49)> 0000 putself ( 1)[Li] 0001 putobject_INT2FIX_1_ 0002 adjuststack 2 0004 putself 0005 opt_send_without_block 0007 putself 0008 opt_send_without_block 0010 send , block in
0013 leave [Re] 0014 putnil 0015 opt_send_without_block 0017 leave == disasm: #@-e:1 (1,39)-(1,45)> 0000 putnil ( 1)[Bc] 0001 leave [Br] ``` The block is getting attached to the `+` operation. I think the problem with this is that when a block is found after a jump, parse.y blindly attaches the block to whatever it finds in the value position. -- 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/