From ac9c83e581fd212c81ad7405c0345f80dd312f37 Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Wed, 19 Nov 2025 09:44:32 -0500 Subject: [PATCH] [ty] Fix flaky tests on macos (#21524) We're seeing flaky test failures on macos, which seems to be caused by different Salsa ID orderings on the different platforms. Constraint set BDDs order their internal nodes based on the Salsa IDs of the interned typevar structs, and we had some code that depended on variable ordering in an unexpected way. This patch definitely fixes the macos test failure on #21414, and hopefully fixes it on #21436, too. --- crates/ty_python_semantic/src/types/constraints.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ty_python_semantic/src/types/constraints.rs b/crates/ty_python_semantic/src/types/constraints.rs index d76b965bd3..eb09335da4 100644 --- a/crates/ty_python_semantic/src/types/constraints.rs +++ b/crates/ty_python_semantic/src/types/constraints.rs @@ -1524,7 +1524,10 @@ impl<'db> InteriorNode<'db> { .exists_one_inner(db, bound_typevar, map, path) }) .unwrap_or(Node::AlwaysFalse); - Node::new(db, self_constraint, if_true, if_false) + // NB: We cannot use `Node::new` here, because the recursive calls might introduce new + // derived constraints into the result, and those constraints might appear before this + // one in the BDD ordering. + Node::new_constraint(db, self_constraint).ite(db, if_true, if_false) } } }