[ruby-core:120962] [Ruby master Bug#21132] Changed postposition `resque` and `if` behavior since Ruby 3.4

Issue #21132 has been reported by watson1978 (Shizuo Fujita). ---------------------------------------- Bug #21132: Changed postposition `resque` and `if` behavior since Ruby 3.4 https://bugs.ruby-lang.org/issues/21132 * Author: watson1978 (Shizuo Fujita) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- When I use postposition `resque` and `if` at same line, the behavior is changed since Ruby 3.4. ## Reproduction ```ruby def foo return "hogehoge" rescue nil if false return "fugafuga" end foo ``` ## Result with Ruby 3.3 ``` irb(main):001> RUBY_VERSION => "3.3.6" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "fugafuga" ``` YARV bytecode ``` ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(6,3)> 0000 definemethod :foo, foo ( 1)[Li] 0003 putself ( 6)[Li] 0004 opt_send_without_block <calldata!mid:foo, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0006 leave == disasm: #<ISeq:foo@<compiled>:1 (1,0)-(4,3)> 0000 putstring "fugafuga" ( 3)[LiCa] 0002 leave ( 4)[Re] ``` ## Result with Ruby 3.4 ``` irb(main):001> RUBY_VERSION => "3.4.1" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "hogehoge" ``` YARV bytecode ``` ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,54)> 0000 putself ( 1)[Li] 0001 opt_getconstant_path <ic:0 RubyVM::InstructionSequence> 0003 opt_getconstant_path <ic:1 DATA> 0005 opt_send_without_block <calldata!mid:new, argc:1, ARGS_SIMPLE> 0007 opt_send_without_block <calldata!mid:disassemble, argc:0, ARGS_SIMPLE> 0009 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE> ``` -- https://bugs.ruby-lang.org/

Issue #21132 has been updated by watson1978 (Shizuo Fujita). When I switched parser to parse.y, it has same result with Ruby 3.3. ``` [~/tmp]$ ruby -v --parser=parse.y t.rb ruby 3.4.1 (2024-12-25 revision 48d4efcb85) [x86_64-linux] "fugafuga" [~/tmp]$ ruby -v --parser=prism t.rb ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] "hogehoge" ``` ---------------------------------------- Bug #21132: Changed postposition `rescue` and `if` behavior since Ruby 3.4 https://bugs.ruby-lang.org/issues/21132#change-111860 * Author: watson1978 (Shizuo Fujita) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- When I use postposition `rescue` and `if` at same line, the behavior is changed since Ruby 3.4. ## Reproduction ```ruby def foo return "hogehoge" rescue nil if false return "fugafuga" end foo ``` ## Result with Ruby 3.3 ``` irb(main):001> RUBY_VERSION => "3.3.6" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "fugafuga" ``` YARV bytecode ``` ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(6,3)> 0000 definemethod :foo, foo ( 1)[Li] 0003 putself ( 6)[Li] 0004 opt_send_without_block <calldata!mid:foo, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0006 leave == disasm: #<ISeq:foo@<compiled>:1 (1,0)-(4,3)> 0000 putstring "fugafuga" ( 3)[LiCa] 0002 leave ( 4)[Re] ``` ## Result with Ruby 3.4 ``` irb(main):001> RUBY_VERSION => "3.4.1" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "hogehoge" ``` YARV bytecode ``` ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,54)> 0000 putself ( 1)[Li] 0001 opt_getconstant_path <ic:0 RubyVM::InstructionSequence> 0003 opt_getconstant_path <ic:1 DATA> 0005 opt_send_without_block <calldata!mid:new, argc:1, ARGS_SIMPLE> 0007 opt_send_without_block <calldata!mid:disassemble, argc:0, ARGS_SIMPLE> 0009 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE> ``` -- https://bugs.ruby-lang.org/

Issue #21132 has been updated by nobu (Nobuyoshi Nakada). Assignee set to prism ---------------------------------------- Bug #21132: Changed postposition `rescue` and `if` behavior since Ruby 3.4 https://bugs.ruby-lang.org/issues/21132#change-111863 * Author: watson1978 (Shizuo Fujita) * Status: Open * Assignee: prism * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- When I use postposition `rescue` and `if` at same line, the behavior is changed since Ruby 3.4. ## Reproduction ```ruby def foo return "hogehoge" rescue nil if false return "fugafuga" end foo ``` ## Result with Ruby 3.3 ``` irb(main):001> RUBY_VERSION => "3.3.6" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "fugafuga" ``` YARV bytecode ``` ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(6,3)> 0000 definemethod :foo, foo ( 1)[Li] 0003 putself ( 6)[Li] 0004 opt_send_without_block <calldata!mid:foo, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0006 leave == disasm: #<ISeq:foo@<compiled>:1 (1,0)-(4,3)> 0000 putstring "fugafuga" ( 3)[LiCa] 0002 leave ( 4)[Re] ``` ## Result with Ruby 3.4 ``` irb(main):001> RUBY_VERSION => "3.4.1" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "hogehoge" ``` YARV bytecode ``` ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,54)> 0000 putself ( 1)[Li] 0001 opt_getconstant_path <ic:0 RubyVM::InstructionSequence> 0003 opt_getconstant_path <ic:1 DATA> 0005 opt_send_without_block <calldata!mid:new, argc:1, ARGS_SIMPLE> 0007 opt_send_without_block <calldata!mid:disassemble, argc:0, ARGS_SIMPLE> 0009 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE> ``` -- https://bugs.ruby-lang.org/

Issue #21132 has been updated by watson1978 (Shizuo Fujita). My problem will be solved by https://github.com/ruby/ruby/commit/c2908613368b2ae404d094a15df61d830fc46dc9 Thanks ---------------------------------------- Bug #21132: Changed postposition `rescue` and `if` behavior since Ruby 3.4 https://bugs.ruby-lang.org/issues/21132#change-111879 * Author: watson1978 (Shizuo Fujita) * Status: Open * Assignee: prism * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- When I use postposition `rescue` and `if` at same line, the behavior is changed since Ruby 3.4. ## Reproduction ```ruby def foo return "hogehoge" rescue nil if false return "fugafuga" end foo ``` ## Result with Ruby 3.3 ``` irb(main):001> RUBY_VERSION => "3.3.6" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "fugafuga" ``` YARV bytecode ``` ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(6,3)> 0000 definemethod :foo, foo ( 1)[Li] 0003 putself ( 6)[Li] 0004 opt_send_without_block <calldata!mid:foo, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0006 leave == disasm: #<ISeq:foo@<compiled>:1 (1,0)-(4,3)> 0000 putstring "fugafuga" ( 3)[LiCa] 0002 leave ( 4)[Re] ``` ## Result with Ruby 3.4 ``` irb(main):001> RUBY_VERSION => "3.4.1" irb(main):002* def foo irb(main):003* return "hogehoge" rescue nil if false irb(main):004* return "fugafuga" irb(main):005> end => :foo irb(main):006> foo => "hogehoge" ``` YARV bytecode ``` ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,54)> 0000 putself ( 1)[Li] 0001 opt_getconstant_path <ic:0 RubyVM::InstructionSequence> 0003 opt_getconstant_path <ic:1 DATA> 0005 opt_send_without_block <calldata!mid:new, argc:1, ARGS_SIMPLE> 0007 opt_send_without_block <calldata!mid:disassemble, argc:0, ARGS_SIMPLE> 0009 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE> ``` -- https://bugs.ruby-lang.org/
participants (2)
-
nobu (Nobuyoshi Nakada)
-
watson1978 (Shizuo Fujita)