Bug Report
A match on a Boolean literal scrutinee is not exhaustive under the cases True and False. After case False, the remaining type of the scrutinee is still Literal[False]. The same cases on a parameter of type bool are exhaustive.
To Reproduce
def f() -> int: match False: case True: return 1 case False: return 0 def g(c: bool) -> int: match True if c else False: case True: return 1 case False: return 0 def h() -> int: match False: case True: return 1 case False: return 0 case other: reveal_type(other) return 2 def k(b: bool) -> int: match b: case True: return 1 case False: return 0
Expected Behavior
No errors, as for k, and other in h unreachable.
Actual Behavior
repro.py:1: error: Missing return statement [return] repro.py:9: error: Missing return statement [return] repro.py:24: note: Revealed type is "Literal[False]" Found 2 errors in 1 file (checked 1 source file)
Integer and string literal scrutinees, such as match 1 with case 1, are exhaustive.
Your Environment
Known mypy bug python/mypy#22202 as an exception to mypy compatibility
Activity
Known mypy bug python/mypy#22202 as an exception to mypy compatibility