@@ -499,14 +499,16 @@ setcomp[expr_ty]:
499499 | '{' a=expression b=for_if_clauses '}' { _Py_SetComp(a, b, EXTRA) }
500500 | invalid_comprehension
501501dict[expr_ty]:
502- | '{' a=[kvpairs ] '}' { _Py_Dict(CHECK(_PyPegen_get_keys(p, a)),
503- CHECK(_PyPegen_get_values(p, a)), EXTRA) }
502+ | '{' a=[double_starred_kvpairs ] '}' {
503+ _Py_Dict(CHECK(_PyPegen_get_keys(p, a)), CHECK(_PyPegen_get_values(p, a)), EXTRA) }
504504dictcomp[expr_ty]:
505505 | '{' a=kvpair b=for_if_clauses '}' { _Py_DictComp(a->key, a->value, b, EXTRA) }
506- kvpairs[asdl_seq*]: a=','.kvpair+ [','] { a }
507- kvpair[KeyValuePair*]:
506+ | invalid_dict_comprehension
507+ double_starred_kvpairs[asdl_seq*]: a=','.double_starred_kvpair+ [','] { a }
508+ double_starred_kvpair[KeyValuePair*]:
508509 | '**' a=bitwise_or { _PyPegen_key_value_pair(p, NULL, a) }
509- | a=expression ':' b=expression { _PyPegen_key_value_pair(p, a, b) }
510+ | kvpair
511+ kvpair[KeyValuePair*]: a=expression ':' b=expression { _PyPegen_key_value_pair(p, a, b) }
510512for_if_clauses[asdl_seq*]:
511513 | for_if_clause+
512514for_if_clause[comprehension_ty]:
@@ -657,6 +659,9 @@ invalid_block:
657659invalid_comprehension:
658660 | ('[' | '(' | '{') a=starred_expression for_if_clauses {
659661 RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "iterable unpacking cannot be used in comprehension") }
662+ invalid_dict_comprehension:
663+ | '{' a='**' bitwise_or for_if_clauses '}' {
664+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "dict unpacking cannot be used in dict comprehension") }
660665invalid_parameters:
661666 | param_no_default* (slash_with_default | param_with_default+) param_no_default {
662667 RAISE_SYNTAX_ERROR("non-default argument follows default argument") }
0 commit comments