-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Improve syntax error for mixing keyword/positional in max patterns #88622
Comments
This got me confused for a sec when doing some live demo: >>> match x:
... case A(y=1, foo):
File "<stdin>", line 2
case A(y=1, foo):
^
SyntaxError: invalid syntax I propose to improve this to: >>> match x:
... case A(y=1, foo):
File "<stdin>", line 2
case A(y=1, foo):
^^^
SyntaxError: cannot mix keyword patterns and positional patterns |
Btw, I noticed this is allowed: >>> match x:
... case A(foo, t=3):
... ...
... but this is not: >>> match x:
... case A(foo=3, t): Is that on pourpose? |
If this is supposed to mirror function calls, maybe the error should be:: >>> match a:
... case A(foo=3, t):
File "<stdin>", line 2
case A(foo=3, t):
^
SyntaxError: positional patterns follow keyword patterns |
Yep, it's intentional. And yep, I like the new error message better. :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: