Project

General

Profile

Bug #21048

Updated by Earlopain (Earlopain _) 1 day ago

With the following code there is a discrepancy in how prism and parse.y consider precedence: 

 ```rb 
 $called = false 
 def foo 
   $called = true 
 end 

 foo rescue nil if false 

 puts "Called: #{$called}" 
 ``` 

 Prism interprets it as `foo `(foo rescue (nil nil) if false)`, false`, not calling the method. `parse.y` does `(foo `foo rescue nil) (nil if false` false)` since at least Ruby 2.0 

 ```sh 
 $ ruby -v 
 ruby 3.5.0dev (2025-01-19T12:44:20Z master f27ed98eff) +PRISM [x86_64-linux] 

 $ ruby code.rb 
 Called: true 

 $ ruby --parser=parse.y code.rb 
 Called: false 
 ```

Back