[syntax-errors] Alternative match patterns bind different names#20682
[syntax-errors] Alternative match patterns bind different names#20682ntBre merged 11 commits intoastral-sh:mainfrom
match patterns bind different names#20682Conversation
|
test Thank you |
ntBre
left a comment
There was a problem hiding this comment.
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 <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
0035102 to
95e7a77
Compare
|
rebased : ) |
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
ntBre
left a comment
There was a problem hiding this comment.
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