Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
x = *a and b
x = *yield x
x = *yield from x
x = *lambda x: x
x = (*a and b,)
x = (42, *yield x)
x = (42, *yield from x)
x = (*lambda x: x,)
x = x := 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_ = *[42]
_ = *{42}
_ = *list()
_ = *(p + q)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_ = 4
_ = [4]
_ = (*[1],)
_ = *[1],
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

foo = 42

[] = *data
() = *data
[] = (*data,)
() = (*data,)
a, b = ab
a = b = c
8 changes: 4 additions & 4 deletions crates/ruff_python_parser/src/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,10 +1127,10 @@ impl<'src> Parser<'src> {
// a + b

// test_err assign_stmt_invalid_value_expr
// x = *a and b
// x = *yield x
// x = *yield from x
// x = *lambda x: x
// x = (*a and b,)
// x = (42, *yield x)
// x = (42, *yield from x)
// x = (*lambda x: x,)
// x = x := 1

let mut value =
Expand Down
15 changes: 14 additions & 1 deletion crates/ruff_python_parser/src/semantic_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl SemanticSyntaxChecker {
Self::duplicate_type_parameter_name(type_params, ctx);
}
}
Stmt::Assign(ast::StmtAssign { targets, .. }) => {
Stmt::Assign(ast::StmtAssign { targets, value, .. }) => {
if let [Expr::Starred(ast::ExprStarred { range, .. })] = targets.as_slice() {
// test_ok single_starred_assignment_target
// (*a,) = (1,)
Expand All @@ -105,6 +105,19 @@ impl SemanticSyntaxChecker {
*range,
);
}

// test_ok assign_stmt_starred_expr_value
// _ = 4
// _ = [4]
// _ = (*[1],)
// _ = *[1],

// test_err assign_stmt_starred_expr_value
// _ = *[42]
// _ = *{42}
// _ = *list()
// _ = *(p + q)
Self::invalid_star_expression(value, ctx);
}
Stmt::Return(ast::StmtReturn { value, range }) => {
if let Some(value) = value {
Expand Down
Loading
Loading