From c2871b5d56b32fce4f87ab43d5150083c33a7a72 Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Sat, 8 Apr 2023 23:23:16 +0100 Subject: [PATCH] Fix #6086 Improve allow-newer-dep messages --- src/Stack/Build/ConstructPlan.hs | 41 ++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/Stack/Build/ConstructPlan.hs b/src/Stack/Build/ConstructPlan.hs index d02bf86cbd..6873821079 100644 --- a/src/Stack/Build/ConstructPlan.hs +++ b/src/Stack/Build/ConstructPlan.hs @@ -907,16 +907,37 @@ addPackageDeps package = do pure True else pure False if allowNewer - then do - warn_ True $ - fillSep - [ style Shell "allow-newer" - , "enabled" - ] - case allowNewerDeps of - Nothing -> pure True - Just boundsIgnoredDeps -> - pure $ packageName package `elem` boundsIgnoredDeps + then case allowNewerDeps of + Nothing -> do + warn_ True $ + fillSep + [ style Shell "allow-newer" + , "enabled" + ] + pure True + Just boundsIgnoredDeps -> do + let pkgName = packageName package + pkgName' = fromString $ packageNameString pkgName + isBoundsIgnoreDep = pkgName `elem` boundsIgnoredDeps + reason = if isBoundsIgnoreDep + then fillSep + [ style Current pkgName' + , flow "is an" + , style Shell "allow-newer-dep" + , flow "and" + , style Shell "allow-newer" + , "enabled" + ] + else fillSep + [ style Current pkgName' + , flow "is not an" + , style Shell "allow-newer-dep" + , flow "although" + , style Shell "allow-newer" + , "enabled" + ] + warn_ isBoundsIgnoreDep reason + pure isBoundsIgnoreDep else do when (isJust allowNewerDeps) $ warn_ False $