Project

General

Profile

Actions

Bug #18080

open

Syntax error on one-line pattern matching

Added by ko1 (Koichi Sasada) 2 months ago. Updated 2 months ago.

Status:
Open
Priority:
Normal
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 #1

Updated by ko1 (Koichi Sasada) 2 months ago

  • Description updated (diff)
Actions

Also available in: Atom PDF