Project

General

Profile

Actions

Bug #21927

closed

Prism: misleading error message for forwarding in lambda argument

Bug #21927: Prism: misleading error message for forwarding in lambda argument

Added by nobu (Nobuyoshi Nakada) 21 days ago. Updated 3 days ago.

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

Description

Even in a forwarding method:

$ ruby --parser=prism -e 'def m(...) ->(...){}; end'
-e: -e:1: syntax error found (SyntaxError)
> 1 | def m(...) ->(...){}; end
    |               ^~~ unexpected ... when the parent method is not forwarding

This message is proper for method arguments:

$ ruby --parser=prism -e 'def m() p(...); end'
-e: -e:1: syntax error found (SyntaxError)
> 1 | def m() p(...); end
    |           ^~~ unexpected ... when the parent method is not forwarding

The message from parse.y is different; "unexpected ... in lambda argument":

$ ruby --parser=parse.y -e 'def m(...) ->(...){}; end'
-e:1: unexpected ... in lambda argument
def m(...) ->(...){}; end
ruby: compile error (SyntaxError)

Updated by Earlopain (Earlopain _) 20 days ago Actions #2

  • Status changed from Open to Closed

Applied in changeset git|6af0de237935f162ee3089b314f0c33911d442da.


[ruby/prism] Fix error message for block/lambda with ... argument

They currently complain that the parent method is not forwarding.
But the actual problem is that these types of arguments simply don't
accept ...

Fixes [Bug #21927]

https://github.com/ruby/prism/commit/0aa2363331

Updated by k0kubun (Takashi Kokubun) 3 days ago Actions #3 [ruby-core:125022]

  • Backport changed from 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED, 4.0: REQUIRED to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED, 4.0: DONE
Actions

Also available in: PDF Atom