Project

General

Profile

Actions

Bug #18878

open

parse.y: Foo::Bar {} is inconsistently rejected

Added by qnighy (Masaki Hara) about 1 month ago. Updated about 1 month ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
[ruby-core:109052]

Description

The following source doesn't parse:

Foo::Bar {}

despite the following:

bar           # local variable or method call
Bar           # constant
bar()         # method call
Bar()         # method call
bar {}        # method call
Bar {}        # method call
bar() {}      # method call
Bar() {}      # method call
Foo::bar      # method call
Foo::Bar      # constant
Foo::bar()    # method call
Foo::Bar()    # method call
Foo::bar {}   # method call
# Foo::Bar {} # SyntaxError
Foo::bar() {} # method call
Foo::Bar() {} # method call

Especially considering Bar {}, this looks like a missing implementation rather than an intentional behavior.

Updated by lhmzhou (Linda Zhou) about 1 month ago

Is there a more descriptive error message, or is SyntaxError the only output provided?

Updated by qnighy (Masaki Hara) about 1 month ago

Is there a more descriptive error message, or is SyntaxError the only output provided?

This is the actual error message:

% ruby -e 'Foo::Bar {}'
-e:1: syntax error, unexpected '{'
Foo::Bar {}
Actions

Also available in: Atom PDF