gh-145019: improve SyntaxError when match patterns bind different names#145939
gh-145019: improve SyntaxError when match patterns bind different names#145939picnixz wants to merge 5 commits intopython:mainfrom
SyntaxError when match patterns bind different names#145939Conversation
…ferent names
Co-authored-by: AN Long <aisk@users.noreply.github.com>
|
Thanks Hugo for the review! I am unavailable this week-end so I will address this next week. If you want to apply your changes, feel free to do so! Otherwise I will do it once I have my laptop. |
|
@hugovk @pablogsal Thanks for the comments! I decided not to compute the exclusive variable names because it's a bit annoying to do so. In pure Python it would be easy as I just need to do >>> match 1:
... case (y, z) | (x, y, z): pass
SyntaxError: pattern 1 does not bind "x" but pattern 3 doesinstead of >>> match 1:
... case (y, z) | (x, y, z): pass
SyntaxError: pattern 1 binds ['y', 'z'] but pattern 3 binds ['x', 'y', 'z']It would be annoying to do so and unledss there are hundreds of variables, I think it's ok to read it from the list. Please tell me whether you want a more precise solution though. |
Uh oh!
There was an error while loading. Please reload this page.