mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-09 21:28:04 +00:00
![]() Two related changes. For context: 1. We were maintaining two separate arenas of `Constraint`s in each use-def map. One was used for narrowing constraints, and the other for visibility constraints. The visibility constraint arena was interned, ensuring that we always used the same ID for any particular `Constraint`. The narrowing constraint arena was not interned. 2. The TDD code relies on _all_ TDD nodes being interned and reduced. This is an important requirement for TDDs to be a canonical form, which allows us to use a single int comparison to test for "always true/false" and to compare two TDDs for equivalence. But we also need to support an individual `Constraint` having multiple values in a TDD evaluation (e.g. to handle a `while` condition having different values the first time it's evaluated vs later times). Previously, we handled that by introducing a "copy" number, which was only there as a disambiguator, to allow an interned, deduplicated constraint ID to appear in the TDD formula multiple times. A better way to handle (2) is to not intern the constraints in the visibility constraint arena! The caller now gets to decide: if they add a `Constraint` to the arena more than once, they get distinct `ScopedConstraintId`s — which the TDD code will treat as distinct variables, allowing them to take on different values in the ternary function. With that in place, we can then consolidate on a single (non-interned) arena, which is shared for both narrowing and visibility constraints. --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
---|---|---|
.. | ||
resources | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml | ||
mdtest.py | ||
mdtest.py.lock |