-
Notifications
You must be signed in to change notification settings - Fork 2k
Some invalid star expressions do not give syntax errors #19077
Copy link
Copy link
Open
Labels
Description
Summary
I noticed some invalid star expressions do not give a SyntaxError. I tested all I could think of, but I might have missed some cases. I also tested if they fail in ast.parse or only in exec, since I think that affects where the SyntaxError should be raised from.
https://play.ruff.rs/140067c2-f088-4992-847a-26a6652cc88e
# SyntaxError: Starred expression cannot be used here
(*
*[],)
# No error
# Should give SyntaxError: Invalid star expression
# Fails in ast.parse
print(*
*[])
# No error
# Should give SyntaxError: can't use starred expression here
# Passes ast.parse, fails in exec
f"{*[]}"
# No error
# Should give SyntaxError: starred assignment target must be in a list or tuple
# Passes ast.parse, fails in exec
for *a in []:...Version
playground
Reactions are currently unavailable