Skip to content

Commit 8703722

Browse files
committed
Fix ordering of BuildPlanCheck results
The comment said that GT was better, but for partial and failing snapshots, LT was returned for better results. The snapshot comparison logic was using <=, so this worked for partial and failing snapshots, but not BuildPlanCheckOk.
1 parent 3dd473b commit 8703722

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Stack/BuildPlan.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,11 @@ data BuildPlanCheck =
658658
-- | Compare 'BuildPlanCheck', where GT means a better plan.
659659
compareBuildPlanCheck :: BuildPlanCheck -> BuildPlanCheck -> Ordering
660660
compareBuildPlanCheck (BuildPlanCheckPartial _ e1) (BuildPlanCheckPartial _ e2) =
661-
compare (Map.size e1) (Map.size e2)
661+
-- Note: order of comparison flipped, since it's better to have fewer errors.
662+
compare (Map.size e2) (Map.size e1)
662663
compareBuildPlanCheck (BuildPlanCheckFail _ e1 _) (BuildPlanCheckFail _ e2 _) =
663664
let numUserPkgs e = Map.size $ Map.unions (Map.elems (fmap deNeededBy e))
664-
in compare (numUserPkgs e1) (numUserPkgs e2)
665+
in compare (numUserPkgs e2) (numUserPkgs e1)
665666
compareBuildPlanCheck BuildPlanCheckOk{} BuildPlanCheckOk{} = EQ
666667
compareBuildPlanCheck BuildPlanCheckOk{} BuildPlanCheckPartial{} = GT
667668
compareBuildPlanCheck BuildPlanCheckOk{} BuildPlanCheckFail{} = GT
@@ -738,7 +739,7 @@ selectBestSnapshot gpds snaps = do
738739
Just old -> loop (Just (betterSnap old new)) rest
739740

740741
betterSnap (s1, r1) (s2, r2)
741-
| compareBuildPlanCheck r1 r2 /= GT = (s1, r1)
742+
| compareBuildPlanCheck r1 r2 /= LT = (s1, r1)
742743
| otherwise = (s2, r2)
743744

744745
reportResult BuildPlanCheckOk {} snap = do

0 commit comments

Comments
 (0)