Skip to content

Improve syntax error message for case 1: statement #138857

@sobolevn

Description

@sobolevn

Feature or enhancement

Right now just case without match produces:

>>> case 1:
  File "<python-input-0>", line 1
    case 1:
         ^
SyntaxError: invalid syntax

I propose to add a better hint:

>>> case 1:
  File "<python-input-0>", line 1
    case 1:
         ^
SyntaxError: case statement must be inside match statement

I have a PR ready.
I also have several other ideas about better error messages for match and case :)

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions