8000 gh-123562: Improve `SyntaxError` message for `case ... as a.b` by sobolevn · Pull Request #123563 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

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

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

Conversation

@sobolevn
Copy link
Member
@sobolevn sobolevn commented Sep 1, 2024

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

Copy link
Contributor
@cfbolz cfbolz left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member
@lysnikolaou lysnikolaou left a comment

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

0