Skip to content

Commit 185ce34

Browse files
committed
Raise error for parenthesized target in walrus expression
1 parent d7b9ea5 commit 185ce34

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Grammar/python.gram

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,9 @@ invalid_expression:
12611261
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "t-string: lambda expressions are not allowed without parentheses") }
12621262

12631263
invalid_named_expression(memo):
1264+
| '(' a=NAME ')' ':=' expression {
1265+
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
1266+
a, "cannot parenthesize target name in assignment expression") }
12641267
| a=expression ':=' expression {
12651268
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
12661269
a, "cannot use assignment expressions with %s", _PyPegen_get_expr_name(a)) }

0 commit comments

Comments
 (0)