[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:
Brent Westbrook 2025-03-26 13:02:42 -04:00 committed by GitHub
parent 5697d21fca
commit d70a3e6753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 966 additions and 1 deletions

View file

@ -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

View file

@ -0,0 +1,2 @@
match 2:
case Class(x) | [x] | x: ...