Skip to content

Commit 110109a

Browse files
committed
Allow walrus in slices
See python/cpython#23317 Raised in #930.
1 parent 59aeceb commit 110109a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

native/libcst/src/parser/grammar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ parser! {
10041004
make_slice(l, col, u, rest)
10051005
}
10061006
/ e:starred_expression() { make_index_from_arg(e) }
1007-
/ v:expression() { make_index(v) }
1007+
/ v:named_expression() { make_index(v) }
10081008

10091009
rule atom() -> Expression<'input, 'a>
10101010
= n:name() { Expression::Name(Box::new(n)) }

native/libcst/tests/fixtures/wonky_walrus.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
if f := x(): pass
1111

1212
f(y:=1)
13-
f(x, y := 1 )
13+
f(x, y := 1 )
14+
15+
_[_:=10]

0 commit comments

Comments
 (0)