summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-20 12:15:44 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-22 08:00:57 -0400
commit93c16b94ebff03c81c2285eb2b622dc62f9bca16 (patch)
treef716d6b23bb31505b10937cf27b6ae1a37e349d2
parentf435d55fe969e739eb92bbb681069020d0622137 (diff)
downloadhaskell-93c16b94ebff03c81c2285eb2b622dc62f9bca16.tar.gz
Relax "suppressing errors" assert in reportWanteds
The assertion in reportWanteds that we aren't suppressing all the Wanted constraints was too strong: it might be the case that we are inside an implication, and have already reported an unsolved Wanted from outside the implication. It is possible that all Wanteds inside the implication have been rewritten by the outer Wanted, so we shouldn't throw an assertion failure in that case. Fixes #21405
-rw-r--r--compiler/GHC/Tc/Errors.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs
index f662495f2c..bbdda9c731 100644
--- a/compiler/GHC/Tc/Errors.hs
+++ b/compiler/GHC/Tc/Errors.hs
@@ -519,10 +519,15 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
-- This check makes sure that we aren't suppressing the only error that will
-- actually stop compilation
- ; massert $
- null simples || -- no errors to report here
- any ignoreConstraint simples || -- one error is ignorable (is reported elsewhere)
- not (all ei_suppress tidy_items) -- not all error are suppressed
+ ; assertPprM
+ ( do { errs_already <- ifErrsM (return True) (return False)
+ ; return $
+ errs_already || -- we already reported an error (perhaps from an outer implication)
+ null simples || -- no errors to report here
+ any ignoreConstraint simples || -- one error is ignorable (is reported elsewhere)
+ not (all ei_suppress tidy_items) -- not all errors are suppressed
+ } )
+ (vcat [text "reportWanteds is suppressing all errors"])
-- First, deal with any out-of-scope errors:
; let (out_of_scope, other_holes) = partition isOutOfScopeHole tidy_holes