`case ...:` generates unclear `SyntaxError` message
Đang mở
@sobolevn đang làm issue này rồi.
Từ ngày 13/9/2025.
interpreter-core
topic-parser
type-feature
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Feature or enhancement
Proposal:
I've noticed that this simple python code sample generates unclear error message:
>>> match 1:
... case ...: ...
File "<stdin>", line 2
case ...: ...
^^^
SyntaxError: invalid syntax
I propose making the error message clearer:
>>> match 1:
... case ...: ...
File "<stdin>", line 2
case ...: ...
^^^
SyntaxError: cannot use case statement with ellipsis
We already have this logic for := expressions:
>>> (a[0] := 1)
File "<stdin>", line 1
(a[0] := 1)
^^^^
SyntaxError: cannot use assignment expressions with subscript
Since case requires some special grammar (not regular python expression) it would be user-friendly to improve this message.
I have a PR ready.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-138865
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Đánh giá
Issue này chưa được đánh giá.