ruff/crates/red_knot_python_semantic/resources/mdtest/conditional
Carl Meyer 2ea63620cf
[red-knot] fix control flow for assignment expressions in elif tests (#15274)
## Summary

The test expression in an `elif` clause is evaluated whether or not we
take the branch. Our control flow model for if/elif chains failed to
reflect this, causing wrong inference in cases where an assignment
expression occurs inside an `elif` test expression. Our "no branch taken
yet" snapshot (which is the starting state for every new elif branch)
can't simply be the pre-if state, it must be updated after visiting each
test expression.

Once we do this, it also means we no longer need to track a vector of
narrowing constraints to reapply for each new branch, since our "branch
not taken" state (which is the initial state for each branch) is
continuously updated to include the negative narrowing constraints of
all previous branches.

Fixes #15033.

## Test Plan

Added mdtests.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-01-05 18:35:29 +00:00
..
if_expression.md Improve mdtests style (#14884) 2024-12-10 13:05:51 +00:00
if_statement.md [red-knot] fix control flow for assignment expressions in elif tests (#15274) 2025-01-05 18:35:29 +00:00
match.md [red-knot] Improve match mdtests (#14951) 2024-12-13 09:50:17 +01:00