Feature or enhancement
Proposal:
Currently, Python raises:
SyntaxError: invalid syntax. Did you mean 'with'?
for switch foo:.
This is confusing and irrelevant, because in many other programming languages, switch is a reserved keyword that serves almost the same function as Python’s match.
Thus, users typing switch almost certainly intended to use match, mistakenly substituting the keyword from other languages, rather than meaning to write a with statement.
Therefore, I believe it’s better to raise:
SyntaxError: invalid syntax. Did you mean 'match'?
in this case.
Additionally, code with typos like mach foo: or matc foo: currently lacks a keyword typo suggestion.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/improve-syntaxerror-message-for-match/107684
Linked PRs
Feature or enhancement
Proposal:
Currently, Python raises:
for
switch foo:.This is confusing and irrelevant, because in many other programming languages, switch is a reserved keyword that serves almost the same function as Python’s match.
Thus, users typing switch almost certainly intended to use match, mistakenly substituting the keyword from other languages, rather than meaning to write a with statement.
Therefore, I believe it’s better to raise:
in this case.
Additionally, code with typos like mach foo: or matc foo: currently lacks a keyword typo suggestion.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/improve-syntaxerror-message-for-match/107684
Linked PRs