[ruby-core:114550] [Ruby master Bug#18080] Syntax error on one-line pattern matching

Issue #18080 has been updated by mdalessio (Mike Dalessio). Looks like YARP already supports this. ``` "> YARP.parse <<~EOF "> p 1 do "> end => a
EOF => #<YARP::ParseResult:0x00007f0f326c9100 @comments=[], @errors=[], @source=#<YARP::Source:0x00007f0f3289cab8 @offsets=[0, 7, 16], @source="p 1 do\nend => a\n">, @value= ProgramNode(0...15)( [:a], StatementsNode(0...15)( [MatchRequiredNode(0...15)( CallNode(0...10)( nil, nil, (0...1), nil, ArgumentsNode(2...3)([IntegerNode(2...3)()]), nil, BlockNode(4...10)([], nil, nil, (4...6), (7...10)), 0, "p" ), LocalVariableWriteNode(14...15)(:a, 0, nil, (14...15), nil), (11...13) )] ) ), @warnings=[]>
----------------------------------------
Bug #18080: Syntax error on one-line pattern matching
https://bugs.ruby-lang.org/issues/18080#change-104355
* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.0dev
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
One line pattern matching with a method return value with parameters which are not surrounded by parenthesis raises syntax error.
I think it is not intentional, but nobu said it's hard to support because of parse.y limitation.
```ruby
p do
end => a
p a #=> nil
p(1) do
end => a
p a #=> 1
p 1 do
end => a
#=>
# syntax error, unexpected =>, expecting end-of-input
# end => a
# ^~
p 1 do
end in a
#=>
# syntax error, unexpected `in', expecting end-of-input
# end in a
# ^~
participants (1)
-
mdalessio (Mike Dalessio)