Skip to content
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

gh-92858: Improve error message for some suites with syntax error before ':' #92894

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wookie184
Copy link

@wookie184 wookie184 commented May 17, 2022

Closes #92858

I left suites like try: as they shouldn't have anything before the colon anyway. There wouldn't be something before the colon that could be fixed, so I think the current error is fine.

Here's some before (first) after (second) examples with the test cases in the PR:

    class C(x for x in L):
           ^
SyntaxError: expected ':'
    class C(x for x in L):
              ^^^
SyntaxError: invalid syntax

    class R&D:
           ^
SyntaxError: expected ':'
    class R&D:
           ^
SyntaxError: invalid syntax

    for x in range 10:
                   ^^
SyntaxError: expected ':'
    for x in range 10:
                   ^^
SyntaxError: invalid syntax

    with block ad something:
               ^^
SyntaxError: expected ':'
    with block ad something:
               ^^
SyntaxError: invalid syntax

    match x x:
             ^
SyntaxError: expected ':'
    match x x:
            ^
SyntaxError: invalid syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants