summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2023-01-09 21:57:03 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-12 15:54:21 -0500
commit1b812b6973a25cb1962e2fc543d2c4ed3cf31f3c (patch)
treed1922268e011e6acfa8c45a9ecd0ac6a98789d0e /compiler
parent73bc162b8427bd34768615fda1c95c41e4797385 (diff)
downloadhaskell-1b812b6973a25cb1962e2fc543d2c4ed3cf31f3c.tar.gz
Fix #22728: Not all diagnostics in safe check are fatal
Also add tests for the issue and -Winferred-safe-imports in general
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Driver/Main.hs28
1 files changed, 15 insertions, 13 deletions
diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs
index 976cf12b55..255ffaf035 100644
--- a/compiler/GHC/Driver/Main.hs
+++ b/compiler/GHC/Driver/Main.hs
@@ -1468,19 +1468,21 @@ checkSafeImports tcg_env
-- restore old errors
logDiagnostics oldErrs
- case (isEmptyMessages safeErrs) of
- -- Failed safe check
- False -> liftIO . throwErrors $ safeErrs
-
- -- Passed safe check
- True -> do
- let infPassed = isEmptyMessages infErrs
- tcg_env' <- case (not infPassed) of
- True -> markUnsafeInfer tcg_env infErrs
- False -> return tcg_env
- when (packageTrustOn dflags) $ checkPkgTrust pkgReqs
- let newTrust = pkgTrustReqs dflags safePkgs infPkgs infPassed
- return tcg_env' { tcg_imports = impInfo `plusImportAvails` newTrust }
+ diag_opts <- initDiagOpts <$> getDynFlags
+ print_config <- initPrintConfig <$> getDynFlags
+ logger <- getLogger
+
+ -- Will throw if failed safe check
+ liftIO $ printOrThrowDiagnostics logger print_config diag_opts safeErrs
+
+ -- No fatal warnings or errors: passed safe check
+ let infPassed = isEmptyMessages infErrs
+ tcg_env' <- case (not infPassed) of
+ True -> markUnsafeInfer tcg_env infErrs
+ False -> return tcg_env
+ when (packageTrustOn dflags) $ checkPkgTrust pkgReqs
+ let newTrust = pkgTrustReqs dflags safePkgs infPkgs infPassed
+ return tcg_env' { tcg_imports = impInfo `plusImportAvails` newTrust }
where
impInfo = tcg_imports tcg_env -- ImportAvails