Fix bug in terms when collapsing unavailable versions in resolver errors (#9877)

Closes https://github.com/astral-sh/uv/issues/9861
Closes https://github.com/pubgrub-rs/pubgrub/issues/297
This commit is contained in:
Zanie Blue 2024-12-13 15:06:39 -06:00 committed by GitHub
parent b2459e6326
commit 4bce1a32ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 15 deletions

View file

@ -673,13 +673,18 @@ fn collapse_unavailable_versions(
// And the package and reason are the same...
if package == other_package && reason == other_reason {
// Collapse both into a new node, with a union of their ranges
let versions = other_versions.union(versions);
let mut terms = terms.clone();
if let Some(Term::Positive(range)) = terms.get_mut(package) {
*range = versions.clone();
}
*tree = DerivationTree::Derived(Derived {
terms: terms.clone(),
terms,
shared_id: *shared_id,
cause1: cause1.clone(),
cause2: Arc::new(DerivationTree::External(External::Custom(
package.clone(),
versions.union(other_versions),
versions,
reason.clone(),
))),
});
@ -696,12 +701,17 @@ fn collapse_unavailable_versions(
// And the package and reason are the same...
if package == other_package && reason == other_reason {
// Collapse both into a new node, with a union of their ranges
let versions = other_versions.union(versions);
let mut terms = terms.clone();
if let Some(Term::Positive(range)) = terms.get_mut(package) {
*range = versions.clone();
}
*tree = DerivationTree::Derived(Derived {
terms: terms.clone(),
terms,
shared_id: *shared_id,
cause1: Arc::new(DerivationTree::External(External::Custom(
package.clone(),
versions.union(other_versions),
versions,
reason.clone(),
))),
cause2: cause2.clone(),