summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-08-05 17:28:57 (GMT)
committerGitHub <noreply@github.com>2021-08-05 17:28:57 (GMT)
commitf5cbea6b1b5fc39cca377c6cc93f222916015fc4 (patch)
treea57f1c3399129af299de14b8952bb77abcb8ba30 /Grammar
parent3d315c311676888201f4a3576e4ee3698684a3a2 (diff)
downloadcpython-f5cbea6b1b5fc39cca377c6cc93f222916015fc4.zip
cpython-f5cbea6b1b5fc39cca377c6cc93f222916015fc4.tar.gz
cpython-f5cbea6b1b5fc39cca377c6cc93f222916015fc4.tar.bz2
bpo-44838: Refine the custom syntax errors for invalid 'if' expressions (GH-27615)
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram2
1 files changed, 1 insertions, 1 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 91d8a69..b107e47 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -1083,7 +1083,7 @@ invalid_expression:
# Soft keywords need to also be ignored because they can be parsed as NAME NAME
| !(NAME STRING | SOFT_KEYWORD) a=disjunction b=expression_without_invalid {
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") }
- | a=disjunction 'if' b=disjunction !'else' { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") }
+ | a=disjunction 'if' b=disjunction !('else'|':') { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") }
invalid_named_expression:
| a=expression ':=' expression {