Project

General

Profile

Actions

Bug #18080

open

Syntax error on one-line pattern matching

Added by ko1 (Koichi Sasada) over 3 years ago. Updated about 1 year ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:104941]

Description

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.

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
#     ^~
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0