ruff/crates/red_knot_python_semantic/resources/mdtest/expression
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
..
attribute.md [red-knot] Review remaining 'possibly unbound' call sites (#14284) 2024-11-11 20:48:49 +01:00
boolean.md [red-knot] Format mdtest Python snippets more concisely (#13905) 2024-10-24 11:09:31 +00:00
if.md [red-knot] Fix Leaking Narrowing Constraint in ast::ExprIf (#14590) 2024-11-25 10:36:37 -08:00