Closed
Description
Slightly related to #2914
Prism parser the following code:
[1,2,3,4] => *a, *b
This results in a FindPatternNode
with an empty list requireds
.
MRI's parser rejects this syntax (I've tried this with Ruby 3.3.3 and a 3.4.0-dev of today):
ruby -e '[1,2,3,4] => *a, *b; p a; p b'
-e:1: syntax error, unexpected *
[1,2,3,4] => *a, *b; p a; p b
ruby: compile error (SyntaxError)
The behaviour is ambiguous: if we enable the prism parser in MRI, it turns out that the whole array is put into the right splat:
ruby --parser=prism -e '[1,2,3,4] => *a, *b; p a; p b'
ruby: warning: The compiler based on the Prism parser is currently experimental and compatibility with the compiler based on parse.y is not yet complete. Please report any issues you find on the `ruby/prism` issue tracker.
[]
[1, 2, 3, 4]
But the result a = [1, 2, 3, 4]; b = []
would have been just as valid. Other combinations like a = [1]; b = [2, 3, 4]
would be valid too, but kind of random.
I would guess a FindPatternNode
with no requireds should be a syntax error.
Metadata
Metadata
Assignees
Labels
No labels