ruff
f98eebdb - [red-knot] Fix Leaking Narrowing Constraint in `ast::ExprIf` (#14590)

Commit
300 days ago
[red-knot] Fix Leaking Narrowing Constraint in `ast::ExprIf` (#14590) ## Summary Closes #14588 ```py x: Literal[42, "hello"] = 42 if bool_instance() else "hello" reveal_type(x) # revealed: Literal[42] | Literal["hello"] _ = ... if isinstance(x, str) else ... # The `isinstance` test incorrectly narrows the type of `x`. # As a result, `x` is revealed as Literal["hello"], but it should remain Literal[42, "hello"]. reveal_type(x) # revealed: Literal["hello"] ``` ## Test Plan mdtest included! --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Author
Parents
Loading