Skip to content

gh-123562: Improve SyntaxError message for case ... as a.b#123563

Merged
lysnikolaou merged 3 commits into
python:mainfrom
sobolevn:issue-123562
Sep 2, 2024
Merged

gh-123562: Improve SyntaxError message for case ... as a.b#123563
lysnikolaou merged 3 commits into
python:mainfrom
sobolevn:issue-123562

Conversation

@sobolevn

@sobolevn sobolevn commented Sep 1, 2024

Copy link
Copy Markdown
Member

Notice that there's still a case that is not reported very well, but it is a rather hard one:

>>> match 1:
...     case x as a + 1: ...
...     
  File "<python-input-0>", line 2
    case x as a + 1: ...
                ^
SyntaxError: invalid syntax

This happens because pattern_capture_target actually matches case x as a but not + 1

Comment thread Grammar/python.gram Outdated

@cfbolz cfbolz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @sobolevn!

@lysnikolaou lysnikolaou merged commit 23f159a into python:main Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants