-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[syntax-errors] Alternative match patterns bind different names
#20682
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
Conversation
|
test Thank you |
ntBre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This looks good overall. I just had a couple of suggestions about test cases and a bit of a simplification/possible performance improvement.
crates/ruff_python_parser/tests/snapshots/invalid_syntax@irrefutable_case_pattern.py.snap
Outdated
Show resolved
Hide resolved
...f_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap
Outdated
Show resolved
Hide resolved
Yes, I think you can stack the comments, although you may need to move the existing one to the previous line like this: |
Sure, have added accordingly. |
|
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
0035102 to
95e7a77
Compare
|
rebased : ) |
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
ntBre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I pushed two small commits, one using the full match pattern's range like CPython does. I think the narrower range could be helpful in the future, but the whole thing seems okay for now. And one renaming the error to DifferentMatchPatternBindings. I still don't totally love the name, but it's not user-facing, so we can always iterate on it if needed.
match patterns bind different names
|
This change seems to now cause a SyntaxError on the following valid code that doesn't use different names: |
Summary
This PR implements semantic syntax error where alternative patterns bind different names
Test Plan
I have written inline tests as directed in #17412