@@ -507,7 +507,7 @@ strings[expr_ty] (memo): a=STRING+ { _PyPegen_concatenate_strings(p, a) }
507507list[expr_ty]:
508508 | '[' a=[star_named_expressions] ']' { _Py_List(a, Load, EXTRA) }
509509listcomp[expr_ty]:
510- | '[' a=named_expression ~ b=for_if_clauses ']' { _Py_ListComp(a, b, EXTRA) }
510+ | '[' a=named_expression b=for_if_clauses ']' { _Py_ListComp(a, b, EXTRA) }
511511 | invalid_comprehension
512512tuple[expr_ty]:
513513 | '(' a=[y=star_named_expression ',' z=[star_named_expressions] { _PyPegen_seq_insert_in_front(p, y, z) } ] ')' {
@@ -516,11 +516,11 @@ group[expr_ty]:
516516 | '(' a=(yield_expr | named_expression) ')' { a }
517517 | invalid_group
518518genexp[expr_ty]:
519- | '(' a=named_expression ~ b=for_if_clauses ')' { _Py_GeneratorExp(a, b, EXTRA) }
519+ | '(' a=named_expression b=for_if_clauses ')' { _Py_GeneratorExp(a, b, EXTRA) }
520520 | invalid_comprehension
521521set[expr_ty]: '{' a=star_named_expressions '}' { _Py_Set(a, EXTRA) }
522522setcomp[expr_ty]:
523- | '{' a=named_expression ~ b=for_if_clauses '}' { _Py_SetComp(a, b, EXTRA) }
523+ | '{' a=named_expression b=for_if_clauses '}' { _Py_SetComp(a, b, EXTRA) }
524524 | invalid_comprehension
525525dict[expr_ty]:
526526 | '{' a=[double_starred_kvpairs] '}' {
@@ -692,6 +692,8 @@ invalid_primary:
692692invalid_comprehension:
693693 | ('[' | '(' | '{') a=starred_expression for_if_clauses {
694694 RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "iterable unpacking cannot be used in comprehension") }
695+ | ('[' | '{') a=star_named_expression ',' [star_named_expressions] {
696+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "did you forget parentheses around the comprehension target?") }
695697invalid_dict_comprehension:
696698 | '{' a='**' bitwise_or for_if_clauses '}' {
697699 RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "dict unpacking cannot be used in dict comprehension") }
0 commit comments