From 1d9829183985b9c5c3b360d50506a732c1e9e802 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 27 Dec 2022 12:06:48 -0800 Subject: [PATCH 1/2] Allow named expression in subscript: `a[b := c]` Signed-off-by: Anders Kaseorg --- parser/python.lalrpop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/python.lalrpop b/parser/python.lalrpop index a73d835..4ec31c0 100644 --- a/parser/python.lalrpop +++ b/parser/python.lalrpop @@ -1023,7 +1023,7 @@ SubscriptList: ast::Expr = { }; Subscript: ast::Expr = { - Test<"all">, + NamedExpressionTest, ?> ":" ?> => { let lower = e1.map(Box::new); let upper = e2.map(Box::new); From 472d664c95375bdc13be65fb705f7ac106f47ba5 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 27 Dec 2022 12:13:50 -0800 Subject: [PATCH 2/2] Allow named expression in set comprehension: `{a := b for c in d}` Signed-off-by: Anders Kaseorg --- parser/python.lalrpop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/python.lalrpop b/parser/python.lalrpop index 4ec31c0..a49379c 100644 --- a/parser/python.lalrpop +++ b/parser/python.lalrpop @@ -1185,7 +1185,7 @@ Atom: ast::Expr = { custom: (), node: ast::ExprKind::Set { elts } }, - "{" > "}" => { + "{" "}" => { ast::Expr { location, end_location: Some(end_location),