From: "k0kubun (Takashi Kokubun) via ruby-core" Date: 2026-11-16T17:42:29+00:00 Subject: [ruby-core:127507] [Ruby Bug#22450] Jump value attaches block in incorrect place under parse.y Issue #22450 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_4_0 commit:3654ad81584296ecf7eb3435b2e0d1641172c068 merged revision(s) commit:31a3aa4e46dd33b5a08708d687ed9f9d3253b55a. ---------------------------------------- Bug #22450: Jump value attaches block in incorrect place under parse.y https://bugs.ruby-lang.org/issues/22450#change-119974 * Author: kddnewton (Kevin Newton) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- 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/