mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
![]() ## 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> |
||
---|---|---|
.. | ||
if_expression.md | ||
if_statement.md | ||
match.md |