Commit ca4f58d8 authored by Andres Löh's avatar Andres Löh
Browse files

Fix handling of manual flags.

This hopefully addresses issue #2280.

The problem was as follows: In the modular solver, manual flags are
enforced. However, in order to respect manual choices by the user,
which are still allowed, we would first check if one of the two choices
had already been disabled, and only if that's not the case, disable
the non-default choice.

However, a manual user constraint is not the only reason why the default
flag choice can be disabled at this point. It can already be disabled
in the validation phase, if it's immediately obvious to the solver at
this point that it can never work. In such a situation (which is
described in #2280), the solver would then fail to respect a manual
flag and allow to change it without user intervention.

The fix seems simple: we now explicitly check whether the flag choice
has been disabled *by the user*, and only then leave it alone.
Otherwise, we enforce the manual flag.
parent f958e32e
......@@ -131,17 +131,18 @@ enforcePackageConstraints pcs = trav go
-- | Transformation that tries to enforce manual flags. Manual flags
-- can only be re-set explicitly by the user. This transformation should
-- be run after user preferences have been enforced. For manual flags,
-- it disables all but the first non-disabled choice.
-- it checks if a user choice has been made. If not, it disables all but
-- the first choice.
enforceManualFlags :: Tree QGoalReasonChain -> Tree QGoalReasonChain
enforceManualFlags = trav go
where
go (FChoiceF qfn gr tr True ts) = FChoiceF qfn gr tr True $
let c = toConflictSet (Goal (F qfn) gr)
in case span isDisabled (P.toList ts) of
(xs, []) -> P.fromList xs -- everything's already disabled, leave everything as is
(xs, y : ys) -> P.fromList (xs ++ y : L.map (\ (b, _) -> (b, Fail c ManualFlag)) ys)
([], y : ys) -> P.fromList (y : L.map (\ (b, _) -> (b, Fail c ManualFlag)) ys)
_ -> ts -- something has been manually selected, leave things alone
where
isDisabled (_, Fail _ _) = True
isDisabled (_, Fail _ GlobalConstraintFlag) = True
isDisabled _ = False
go x = x
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment