Project

General

Profile

Actions

Bug #20751

closed

Regression in Prism related to use of return in default argument values

Added by jeremyevans0 (Jeremy Evans) 8 months ago. Updated 8 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:119242]

Description

All versions of parse.y dating at least back to Ruby 1.8.7, and Prism in both Ruby 3.3.5 and 3.4.0preview1, correctly parses this code:

class A
  def foo(b = nil || (return))
  end
end

The master branch, unless --parser=parse.y is used, now considers this a SyntaxError:

-: -:2: syntax error found (SyntaxError)
  1 | class A
> 2 |   def foo(b = nil || (return))
    |                       ^~~~~~ Invalid return in class/module body
  3 |   end
  4 | end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0