facebook / facebook/pyrefly

Handling duplicate Label Detection in Match Statements

Open
#1,440 3 comments 0 reactions 1 assignee Claimed by @stroxler View on GitHub
stale typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```
def test_duplicate_match(value: str) -> int:
match value:
case "foo":
return 1
case "foo": # Duplicate label, dead path should error here
return 2
case _:
return 0
```
`No errors!`

Pyrefly does not detect duplicate labels within a Python match statement. When the same label appears more than once, Pyre fails to flag this, resulting in dead path code that is never executed.

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSImMYABAC7x0D6mArsVBAMaoNMC2vLgAsAFADdUUVjEQ04dAE4BKGgFoAfDQjo6iADroaxmoLoiak6bMMm7NHnBg194XLlcGj9n4ph1WRSMARlsfB1QnFzcPJGMAYhoAEXZOHgYaKFRsGCgAGhoqVEwaYl5heWFcVigSmEVFXEUaYXqYMPCTPwCgmgAmDvtHZyYvTrtuwKMABhA8kFY6aDgSckQQRIBVJc46UhowVnQuJdx0OENDKlowJrMmdFZ%2BHMVRfDkdOlVNeSUxrv8UwOrgAck8XnJgPgAL6uQxzEBkPxgKCkQh0XD8KAURIABVIyNR8gwOAIDjOkAA5oFeBAzoRDIkAMowZzCOh0YhwRAAeh5SOoqMITUpPJg6B5mFwXDgPK4FIg1MUtLOPIOTRoqEk0GysHJ6CpNNORlwxGNK0MZDoVXQanE9TgdKMAF5ogBmQjBAYgeHQ%2BaoE4Qe0AMWgMAoaCweCIZBA0KAA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.