Skip to content

Commit

Permalink
fix: issue where a union clause has no candidates (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra authored Jan 2, 2025
1 parent f89c0b2 commit f6537fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,9 +1089,12 @@ impl<D: DependencyProvider, RT: AsyncRuntime> Solver<D, RT> {

// Find the first candidate that is not yet assigned a value or find the first
// value that makes this clause true.
candidate = candidates
.iter()
.try_fold(None, |first_candidate, &candidate| {
candidate = candidates.iter().try_fold(
match candidate {
ControlFlow::Continue(x) => x,
_ => None,
},
|first_candidate, &candidate| {
let assigned_value =
self.decision_tracker.assigned_value(candidate.into());
ControlFlow::Continue(match assigned_value {
Expand Down Expand Up @@ -1137,7 +1140,8 @@ impl<D: DependencyProvider, RT: AsyncRuntime> Solver<D, RT> {
}
},
})
});
},
);

// Stop searching if we found a candidate that makes the clause true.
if candidate.is_break() {
Expand Down
11 changes: 11 additions & 0 deletions tests/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,17 @@ fn test_snapshot_union_requirements() {
));
}

#[test]
fn test_union_empty_requirements() {
let provider = BundleBoxProvider::from_packages(&[("a", 1, vec!["b 1 | c"]), ("b", 1, vec![])]);

let result = solve_snapshot(provider, &["a"]);
assert_snapshot!(result, @r"
a=1
b=1
");
}

#[test]
fn test_root_constraints() {
let provider =
Expand Down

0 comments on commit f6537fc

Please sign in to comment.