Actions
Bug #18878
openparse.y: Foo::Bar {} is inconsistently rejected
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
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) over 2 years ago
Is there a more descriptive error message, or is SyntaxError
the only output provided?
Updated by qnighy (Masaki Hara) over 2 years 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 {}
Updated by jeremyevans0 (Jeremy Evans) about 1 year ago
It looks like this will be fixed by YARP:
$ ruby -r yarp -e "pp YARP.parse('Foo::Bar {}')"
#<YARP::ParseResult:0x00000b1512acc448
@comments=[],
@errors=[],
@source=#<YARP::Source:0x00000b14749d6690 @offsets=[0], @source="Foo::Bar {}">,
@value=
ProgramNode(0...11)(
[],
StatementsNode(0...11)(
[CallNode(0...11)(ConstantReadNode(0...3)(), (3...5), (5...8), nil, nil, nil, BlockNode(9...11)([], nil, nil, (9...10), (10...11)), 0, "Bar")]
)
),
@warnings=[]>
Actions
Like0
Like0Like0Like0