-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Improve SyntaxError message for case ... as a.b #123562
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-parsertype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-parsertype-featureA feature request or enhancementA feature request or enhancement
Feature or enhancement
There's already a similar rule:
cpython/Grammar/python.gram
Line 1378 in 084e0f3
But, it has two problems:
as a.b, becauseamatchesNAMEinvalid pattern targetMy proposed change:
Why is it safe?
Here's how the parent rule is defined:
So, if
pattern=or_pattern 'as' target=pattern_capture_targetwith a valid'as' NAMEis matched, we won't fall to the nextinvalid_rule.Proposed result:
Refs #123440
Linked PRs
SyntaxErrormessage forcase ... as a.b#123563