ruff/crates/red_knot_python_semantic
cake-monotone f98eebdbab
[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>
2024-11-25 10:36:37 -08:00
..
resources [red-knot] Fix Leaking Narrowing Constraint in ast::ExprIf (#14590) 2024-11-25 10:36:37 -08:00
src [red-knot] Fix Leaking Narrowing Constraint in ast::ExprIf (#14590) 2024-11-25 10:36:37 -08:00
tests [red-knot] Improve mdtest output (#14213) 2024-11-11 11:03:41 +00:00
build.rs Modernize build scripts (#13837) 2024-10-20 22:35:35 +01:00
Cargo.toml Workspace discovery (#14308) 2024-11-15 19:20:15 +01:00