[red-knot] Type narrow in else clause (#13918)

## Summary

Add support for type narrowing in elif and else scopes as part of
#13694.

## Test Plan

- mdtest
- builder unit test for union negation.

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
TomerBin
2024-10-26 19:22:57 +03:00
committed by GitHub
parent 3006d6da23
commit 35f007f17f
17 changed files with 363 additions and 53 deletions

View File

@@ -23,7 +23,8 @@ reveal_type(b) # revealed: Unknown
## Function return
```py
def int_instance() -> int: ...
def int_instance() -> int:
return 42
a = "abcde"[int_instance()]
# TODO: Support overloads... Should be `str`