Skip to content

Commit 1abe7e3

Browse files
committed
Allow star expression for list elements
1 parent fdbef41 commit 1abe7e3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

parser/src/python.lalrpop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ ExpressionList2: Vec<ast::Expression> = {
10081008
// - a single expression
10091009
// - a single expression followed by a trailing comma
10101010
TestList: ast::Expression = {
1011-
<location:@L> <elements:OneOrMore<Test>> <trailing_comma: ","?> => {
1011+
<location:@L> <elements:OneOrMore<TestOrStarExpr>> <trailing_comma: ","?> => {
10121012
if elements.len() == 1 && trailing_comma.is_none() {
10131013
elements.into_iter().next().unwrap()
10141014
} else {

tests/snippets/list.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,3 +632,6 @@ def iadd_slice():
632632
assert it.__length_hint__() == 3
633633
assert list(it) == [3,2,1]
634634
assert it.__length_hint__() == 0
635+
636+
a = [*[1, 2], 3, *[4, 5]]
637+
assert a == [1, 2, 3, 4, 5]

0 commit comments

Comments
 (0)