From: "watson1978 (Shizuo Fujita) via ruby-core" Date: 2025-02-13T02:44:35+00:00 Subject: [ruby-core:120963] [Ruby master Bug#21132] Changed postposition `rescue` and `if` behavior since Ruby 3.4 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: #@:1 (1,0)-(6,3)> 0000 definemethod :foo, foo ( 1)[Li] 0003 putself ( 6)[Li] 0004 opt_send_without_block 0006 leave == disasm: #: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: #@:1 (1,0)-(1,54)> 0000 putself ( 1)[Li] 0001 opt_getconstant_path 0003 opt_getconstant_path 0005 opt_send_without_block 0007 opt_send_without_block 0009 opt_send_without_block ``` -- 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/