diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2020-11-16 23:38:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 23:38:58 (GMT) |
commit | 2b800ef809eefbc96a536e4b43a8285f2353f64d (patch) | |
tree | a7324a40ab4f2e34a8581fd670554dde2688ada4 /Parser | |
parent | cf70854f10096446115408b5a94030b30594a459 (diff) | |
download | cpython-2b800ef809eefbc96a536e4b43a8285f2353f64d.zip cpython-2b800ef809eefbc96a536e4b43a8285f2353f64d.tar.gz cpython-2b800ef809eefbc96a536e4b43a8285f2353f64d.tar.bz2 |
bpo-42374: Allow unparenthesized walrus in genexps (GH-23319) (GH-23329)
This fixes a regression that was introduced by the new parser.
(cherry picked from commit cb3e5ed0716114393696ec7201e51fe0595eab4f)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen/parse.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 97cefa9..c78abfa 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -11381,7 +11381,7 @@ group_rule(Parser *p) return _res; } -// genexp: '(' expression ~ for_if_clauses ')' | invalid_comprehension +// genexp: '(' named_expression ~ for_if_clauses ')' | invalid_comprehension static expr_ty genexp_rule(Parser *p) { @@ -11401,12 +11401,12 @@ genexp_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '(' expression ~ for_if_clauses ')' + { // '(' named_expression ~ for_if_clauses ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' expression ~ for_if_clauses ')'")); + D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' named_expression ~ for_if_clauses ')'")); int _cut_var = 0; Token * _literal; Token * _literal_1; @@ -11415,7 +11415,7 @@ genexp_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = expression_rule(p)) // expression + (a = named_expression_rule(p)) // named_expression && (_cut_var = 1) && @@ -11424,7 +11424,7 @@ genexp_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' expression ~ for_if_clauses ')'")); + D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' named_expression ~ for_if_clauses ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11444,7 +11444,7 @@ genexp_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' expression ~ for_if_clauses ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' named_expression ~ for_if_clauses ')'")); if (_cut_var) { D(p->level--); return NULL; |