From 649c7bce582b9ffb47d5948307de8937cdcfe47d Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Sun, 14 Dec 2025 21:51:56 -0500 Subject: [PATCH] more comment --- crates/ty_python_semantic/src/types/constraints.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ty_python_semantic/src/types/constraints.rs b/crates/ty_python_semantic/src/types/constraints.rs index 4a18f83410..5fe7584280 100644 --- a/crates/ty_python_semantic/src/types/constraints.rs +++ b/crates/ty_python_semantic/src/types/constraints.rs @@ -1326,7 +1326,9 @@ impl<'db> Node<'db> { } // If we reach the `true` terminal, the path we've been following represents one - // representative type. + // representative type. Before constructing the final lower and upper bound, sort + // the constraints by their source order. This should give us a consistently + // ordered specialization, regardless of the variable ordering of the original BDD. current_bounds.sort_unstable_by_key(|bounds| bounds.source_order); let greatest_lower_bound = UnionType::from_elements(db, current_bounds.iter().map(|bounds| bounds.lower));