From: "mdalessio (Mike Dalessio) via ruby-core" Date: 2023-08-25T17:23:06+00:00 Subject: [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 => #, @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 # ^~ ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/