-
Notifications
You must be signed in to change notification settings - Fork 165
Prism accepts double wildcard with no required fields in pattern match #2915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The same thing can happen with an [1,2,3,4] => *a, *b, 4 This too gets rejected by MRI
Switching the parser to Prism (ruby 3.4-dev, the default included prism 0.30) results in a segfault. In this case, MRI even rejects syntax that I would think is not ambiguous:
This still results in a segfault when using |
Thanks @herwinw! I'll get these fixed |
Earlopain
added a commit
to Earlopain/ruby-prism
that referenced
this issue
May 19, 2025
Earlopain
added a commit
to Earlopain/ruby-prism
that referenced
this issue
May 19, 2025
Earlopain
added a commit
to Earlopain/ruby-prism
that referenced
this issue
May 19, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Slightly related to #2914
Prism parser the following code:
This results in a
FindPatternNode
with an empty listrequireds
.MRI's parser rejects this syntax (I've tried this with Ruby 3.3.3 and a 3.4.0-dev of today):
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:
But the result
a = [1, 2, 3, 4]; b = []
would have been just as valid. Other combinations likea = [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.The text was updated successfully, but these errors were encountered: