Project

General

Profile

Actions

Bug #21097

open

`x = a rescue b in c` and `def f = a rescue b in c` parsed differently between parse.y and prism

Added by tompng (tomoya ishida) 24 days ago. Updated 8 days ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-01-27T08:19:32Z master c3c7300b89) +YJIT +MN +PRISM [arm64-darwin22]
[ruby-core:120819]

Description

x = a rescue b in c
(x = (a rescue b)) in c # parse.y, prism(ruby 3.4)
x = (a rescue (b in c)) # prism(ruby 3.5)
def f = a rescue b in c #=> true(parse.y), :f(prism)
(def f = (a rescue b)) in c # parse.y
def f = (a rescue (b in c)) # prism

There is no difference between prism and parse.y parsing these codes

a rescue b in c # a rescue (b in c)
x = a rescue b # x = (a rescue b)
x = b in c # (x = b) in c
def f = a rescue b # def f = (a rescue b)
def f = b in c # (def f = a) in b

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #21132: Changed postposition `rescue` and `if` behavior since Ruby 3.4ClosedprismActions

Updated by tompng (tomoya ishida) 24 days ago

not in and not rescue has the same problem

$ ruby --parser=parse.y -e "def f = not 1 in 2; p f"
false
$ ruby --parser=prism   -e "def f = not 1 in 2; p f"
true
$ ruby --parser=parse.y -e "def f = not a rescue true; p f"
false
$ ruby --parser=prism   -e "def f = not a rescue true; p f"
true

Updated by tenderlovemaking (Aaron Patterson) 24 days ago

  • Assignee set to prism
Actions #3

Updated by hsbt (Hiroshi SHIBATA) 10 days ago

  • Status changed from Open to Assigned
Actions #4

Updated by nobu (Nobuyoshi Nakada) 9 days ago

  • Related to Bug #21132: Changed postposition `rescue` and `if` behavior since Ruby 3.4 added

Updated by matz (Yukihiro Matsumoto) 9 days ago

The behavior of Prism in 3.5 is close to my intention.

Matz.

Updated by kddnewton (Kevin Newton) 9 days ago

In this case, I'm not sure if the assignee should be prism, if we now have the desired behavior. @tompng (tomoya ishida) does this match your understanding?

Updated by tompng (tomoya ishida) 8 days ago

  • Status changed from Assigned to Open
  • Assignee deleted (prism)
Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0Like0Like0