diff --git a/crates/uv-resolver/src/marker.rs b/crates/uv-resolver/src/marker.rs index 01209c00d..3c836779d 100644 --- a/crates/uv-resolver/src/marker.rs +++ b/crates/uv-resolver/src/marker.rs @@ -18,14 +18,14 @@ use pubgrub::range::Range as PubGrubRange; pub(crate) fn is_disjoint(first: &MarkerTree, second: &MarkerTree) -> bool { let (expr1, expr2) = match (first, second) { (MarkerTree::Expression(expr1), MarkerTree::Expression(expr2)) => (expr1, expr2), - // `And` expressions are disjoint if any clause is disjoint. - (other, MarkerTree::And(exprs)) | (MarkerTree::And(exprs), other) => { - return exprs.iter().any(|tree1| is_disjoint(tree1, other)) - } // `Or` expressions are disjoint if all clauses are disjoint. (other, MarkerTree::Or(exprs)) | (MarkerTree::Or(exprs), other) => { return exprs.iter().all(|tree1| is_disjoint(tree1, other)) } + // `And` expressions are disjoint if any clause is disjoint. + (other, MarkerTree::And(exprs)) | (MarkerTree::And(exprs), other) => { + return exprs.iter().any(|tree1| is_disjoint(tree1, other)); + } }; match (expr1, expr2) { @@ -529,6 +529,15 @@ mod tests { "os_name == 'a' or platform_version == '1'", "os_name == 'a' or platform_version == '2'" )); + + assert!(is_disjoint( + "sys_platform == 'darwin' and implementation_name == 'pypy'", + "sys_platform == 'bar' or implementation_name == 'foo'", + )); + assert!(is_disjoint( + "sys_platform == 'bar' or implementation_name == 'foo'", + "sys_platform == 'darwin' and implementation_name == 'pypy'", + )); } fn test_version_bounds_disjointness(version: &str) {