Skip to content

Commit 463ebb9

Browse files
committed
Fix bug in dependency solver stanza preferences.
Previously, stanza choices were set to "weak" even when the preference did not apply.
1 parent b9ef0eb commit 463ebb9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

cabal-install/Distribution/Solver/Modular/Preference.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,19 @@ preferLatestOrdering (I v1 _) (I v2 _) = compare v1 v2
113113
preferPackageStanzaPreferences :: (PN -> PackagePreferences) -> Tree a -> Tree a
114114
preferPackageStanzaPreferences pcs = trav go
115115
where
116-
go (SChoiceF qsn@(SN (PI (Q pp pn) _) s) gr _tr ts) | primaryPP pp =
117-
let PackagePreferences _ _ spref = pcs pn
118-
enableStanzaPref = s `elem` spref
119-
-- move True case first to try enabling the stanza
120-
ts' | enableStanzaPref = P.sortByKeys (flip compare) ts
121-
| otherwise = ts
122-
in SChoiceF qsn gr (WeakOrTrivial True) ts'
116+
go (SChoiceF qsn@(SN (PI (Q pp pn) _) s) gr _tr ts)
117+
| primaryPP pp && enableStanzaPref pn s =
118+
-- move True case first to try enabling the stanza
119+
let ts' = P.sortByKeys (flip compare) ts
120+
-- defer the choice by setting it to weak
121+
in SChoiceF qsn gr (WeakOrTrivial True) ts'
123122
go x = x
124123

124+
enableStanzaPref :: PN -> OptionalStanza -> Bool
125+
enableStanzaPref pn s =
126+
let PackagePreferences _ _ spref = pcs pn
127+
in s `elem` spref
128+
125129
-- | Helper function that tries to enforce a single package constraint on a
126130
-- given instance for a P-node. Translates the constraint into a
127131
-- tree-transformer that either leaves the subtree untouched, or replaces it

0 commit comments

Comments
 (0)