mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
[syntax-errors] Multiple assignments in case
pattern (#16957)
Summary -- This PR detects multiple assignments to the same name in `case` patterns by recursively visiting each pattern. Test Plan -- New inline tests.
This commit is contained in:
parent
5697d21fca
commit
d70a3e6753
6 changed files with 966 additions and 1 deletions
|
@ -0,0 +1,10 @@
|
|||
match 2:
|
||||
case [y, z, y]: ... # MatchSequence
|
||||
case [y, z, *y]: ... # MatchSequence
|
||||
case [y, y, y]: ... # MatchSequence multiple
|
||||
case {1: x, 2: x}: ... # MatchMapping duplicate pattern
|
||||
case {1: x, **x}: ... # MatchMapping duplicate in **rest
|
||||
case Class(x, x): ... # MatchClass positional
|
||||
case Class(x=1, x=2): ... # MatchClass keyword
|
||||
case [x] | {1: x} | Class(x=1, x=2): ... # MatchOr
|
||||
case x as x: ... # MatchAs
|
|
@ -0,0 +1,2 @@
|
|||
match 2:
|
||||
case Class(x) | [x] | x: ...
|
Loading…
Add table
Add a link
Reference in a new issue