From eea63345ceb15b36812a218f093391f3ea4f14b3 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Wed, 19 Jan 2022 14:52:22 +0100 Subject: [PATCH] Read the version_restriction from the notes This has the advantage that it will not fail when there aren't any FailsRestriction rejections. --- lib/opam_solve.ml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/opam_solve.ml b/lib/opam_solve.ml index 722307c6b..7eea5e080 100644 --- a/lib/opam_solve.ml +++ b/lib/opam_solve.ml @@ -263,21 +263,25 @@ module Make_solver (Context : OPAM_MONOREPO_CONTEXT) : | None -> (* short-circuit skip of fold *) let ( let* ) a f = match a with Some a -> f a | None -> acc in - let* pkg_name = Solver.package_name pkg in - let rejects, _reason = - Solver.Diagnostics.Component.rejects component - in + let notes = Solver.Diagnostics.Component.notes component in (* In the rejected candidates, try to find one where it had failed a version restriction and extract that one *) let* version_restriction = List.find_map - ~f:(fun (_model, reason) -> - match reason with - | `FailsRestriction restriction -> - let _, version_restriction = Solver.formula restriction in - Some version_restriction + ~f:(function + | Restricts (_other_role, _impl, restrictions) -> ( + match restrictions with + | [] -> None + | restriction :: _ -> + let _, version_restriction = + Solver.formula restriction + in + Some version_restriction) | _ -> None) - rejects + notes + in + let rejects, _reason = + Solver.Diagnostics.Component.rejects component in (* find only the model rejections that is those that we have rejected as e.g. not building with dune *) let model_rejected =