Skip to content

Commit 0368491

Browse files
committed
Add and use invalid_mapping_pattern
1 parent 5213f1b commit 0368491

File tree

2 files changed

+641
-506
lines changed

2 files changed

+641
-506
lines changed

Grammar/python.gram

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ mapping_pattern[pattern_ty]:
626626
CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, items)),
627627
NULL,
628628
EXTRA) }
629+
| invalid_mapping_pattern
629630

630631
items_pattern[asdl_seq*]:
631632
| ','.key_value_pattern+
@@ -1490,6 +1491,10 @@ invalid_class_pattern:
14901491
PyPegen_first_item(a, pattern_ty),
14911492
PyPegen_last_item(a, pattern_ty),
14921493
"positional patterns follow keyword patterns") }
1494+
invalid_mapping_pattern:
1495+
| '{' (items_pattern ','?)? rest=double_star_pattern ',' items_pattern ','? '}' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
1496+
rest,
1497+
"double star pattern must be the last (right-most) subpattern in the mapping pattern") }
14931498
invalid_class_argument_pattern[asdl_pattern_seq*]:
14941499
| [positional_patterns ','] keyword_patterns ',' a=positional_patterns { a }
14951500
invalid_if_stmt:

0 commit comments

Comments
 (0)