mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
Fix range of unparenthesized tuple subject in match statement (#8101)
## Summary This was just a bug in the parser ranges, probably since it was initially implemented. Given `match n % 3, n % 5: ...`, the "subject" (i.e., the tuple of two binary operators) was using the entire range of the `match` statement. Closes https://github.com/astral-sh/ruff/issues/8091. ## Test Plan `cargo test`
This commit is contained in:
parent
95702e408f
commit
d6a4283003
7 changed files with 2763 additions and 2369 deletions
|
@ -564,3 +564,17 @@ match pattern:
|
|||
# comment
|
||||
a, b,):
|
||||
pass
|
||||
|
||||
# Tuple subject.
|
||||
match n % 3, n % 5:
|
||||
case 0, 0:
|
||||
# n is divisible by both 3 and 5
|
||||
print("FizzBuzz")
|
||||
case 0, _:
|
||||
# n is divisible by 3, but not 5
|
||||
print("Fizz")
|
||||
case _, 0:
|
||||
# n is divisible by 5, but not 3
|
||||
print("Buzz")
|
||||
case _:
|
||||
print(n)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue