summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram13
1 files changed, 11 insertions, 2 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 9087c7a..cca9209 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -640,8 +640,17 @@ invalid_assignment:
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") }
| a=expression ':' expression ['=' annotated_rhs] {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "illegal target for annotation") }
- | a=expression ('=' | augassign) (yield_expr | star_expressions) {
- RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot assign to %s", _PyPegen_get_expr_name(a)) }
+ | a=star_expressions '=' (yield_expr | star_expressions) {
+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
+ _PyPegen_get_invalid_target(a),
+ "cannot assign to %s", _PyPegen_get_expr_name(_PyPegen_get_invalid_target(a))) }
+ | a=star_expressions augassign (yield_expr | star_expressions) {
+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
+ a,
+ "'%s' is an illegal expression for augmented assignment",
+ _PyPegen_get_expr_name(a)
+ )}
+
invalid_block:
| NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block") }
invalid_comprehension: