Skip to content

Commit

Permalink
Allow walrus in slices
Browse files Browse the repository at this point in the history
See python/cpython#23317

Raised in #930.
  • Loading branch information
zsol committed May 27, 2023
1 parent 59aeceb commit 110109a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion native/libcst/src/parser/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ parser! {
make_slice(l, col, u, rest)
}
/ e:starred_expression() { make_index_from_arg(e) }
/ v:expression() { make_index(v) }
/ v:named_expression() { make_index(v) }

rule atom() -> Expression<'input, 'a>
= n:name() { Expression::Name(Box::new(n)) }
Expand Down
4 changes: 3 additions & 1 deletion native/libcst/tests/fixtures/wonky_walrus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
if f := x(): pass

f(y:=1)
f(x, y := 1 )
f(x, y := 1 )

_[_:=10]

0 comments on commit 110109a

Please sign in to comment.