@@ -650,6 +650,8 @@ dict[expr_ty]:
650650 CHECK(asdl_expr_seq*, _PyPegen_get_keys(p, a)),
651651 CHECK(asdl_expr_seq*, _PyPegen_get_values(p, a)),
652652 EXTRA) }
653+ | '{' invalid_double_starred_kvpairs '}'
654+
653655dictcomp[expr_ty]:
654656 | '{' a=kvpair b=for_if_clauses '}' { _PyAST_DictComp(a->key, a->value, b, EXTRA) }
655657 | invalid_dict_comprehension
@@ -882,3 +884,12 @@ invalid_elif_stmt:
882884 | 'elif' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
883885invalid_while_stmt:
884886 | 'while' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
887+
888+ invalid_double_starred_kvpairs:
889+ | ','.double_starred_kvpair+ ',' invalid_kvpair
890+ | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use a starred expression in a dictionary value") }
891+ | expression a=':' &('}'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
892+ invalid_kvpair:
893+ | a=expression !(':') { RAISE_SYNTAX_ERROR("':' expected after dictionary key") }
894+ | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use a starred expression in a dictionary value") }
895+ | expression a=':' {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
0 commit comments