ruff/crates/ty_python_semantic
Carl Meyer e0f3a064b9
[ty] don't iterate over a hashset (#21649)
## Summary

This caused "deterministic but chaotic" ordering of some intersection
types in diagnostics. When calling a union, we infer the argument type
once per matching parameter type, intersecting the inferred types for
the argument expression, and we did that in an unpredictable order.

We do need a hashset here for de-duplication. Sometimes we call large
unions where the type for a given parameter is the same across the
union, we should infer the argument once per parameter type, not once
per union element. So use an `FxIndexSet` instead of an `FxHashSet`.

## Test Plan

With this change, switching between `main` and
https://github.com/astral-sh/ruff/pull/21646 no longer changes the
ordering of the intersection type in the test in
cca3a8045d
2025-11-26 16:39:49 -08:00
..
resources [ty] handle recursive type inference properly (#20566) 2025-11-26 08:50:26 -08:00
src [ty] don't iterate over a hashset (#21649) 2025-11-26 16:39:49 -08:00
tests [ty] handle recursive type inference properly (#20566) 2025-11-26 08:50:26 -08:00
build.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
Cargo.toml [ty] Add 'remove unused ignore comment' code action (#21582) 2025-11-25 08:08:21 -05:00
mdtest.py [ty] Press 'enter' to rerun all mdtests (#21427) 2025-11-13 15:34:17 +01:00
mdtest.py.lock Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00