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) } } }