diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index 8c85685d29e8f773d7a50a9ff02456e7db7a848c..2210716fd5fa10437a38edb4e0033c9442e501f9 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -2080,7 +2080,7 @@ defaultLintFlags = LF { lf_check_global_ids = False newtype LintM a = LintM { unLintM :: LintEnv -> - WarnsAndErrs -> -- Error and warning messages so far + WarnsAndErrs -> -- Warning and error messages so far (Maybe a, WarnsAndErrs) } -- Result and messages (if any) type WarnsAndErrs = (Bag MsgDoc, Bag MsgDoc) @@ -2189,10 +2189,13 @@ data LintLocInfo | InCo Coercion -- Inside a coercion initL :: DynFlags -> LintFlags -> InScopeSet - -> LintM a -> WarnsAndErrs -- Errors and warnings + -> LintM a -> WarnsAndErrs -- Warnings and errors initL dflags flags in_scope m = case unLintM m env (emptyBag, emptyBag) of - (_, errs) -> errs + (Just _, errs) -> errs + (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + "without reporting an error message") empty where env = LE { le_flags = flags , le_subst = mkEmptyTCvSubst in_scope