summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2010-10-08 09:43:48 +0000
committersimonpj@microsoft.com <unknown>2010-10-08 09:43:48 +0000
commit5e86045ae5f90d9138e395fde5792e50ac8f8afd (patch)
tree933ce346909db9e6202b69481cd3071461bb7922 /compiler
parent2b0c363dcaa51295571bc72a2fa0b72bf0ff353a (diff)
downloadhaskell-5e86045ae5f90d9138e395fde5792e50ac8f8afd.tar.gz
Suppress knock-on typechecker errors
The error cascade caused puzzling errors in T4093b, and suppressing some seems like a good plan. Very few test outputs change.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/typecheck/TcErrors.lhs23
1 files changed, 17 insertions, 6 deletions
diff --git a/compiler/typecheck/TcErrors.lhs b/compiler/typecheck/TcErrors.lhs
index 293b3a7958..0ade93c29f 100644
--- a/compiler/typecheck/TcErrors.lhs
+++ b/compiler/typecheck/TcErrors.lhs
@@ -33,7 +33,7 @@ import Outputable
import DynFlags
import StaticFlags( opt_PprStyle_Debug )
import Data.List( partition )
-import Control.Monad( unless )
+import Control.Monad( when, unless )
\end{code}
%************************************************************************
@@ -117,17 +117,28 @@ reportTidyImplic ctxt implic
reportTidyWanteds :: ReportErrCtxt -> WantedConstraints -> TcM ()
reportTidyWanteds ctxt unsolved
- = do { let (flats, implics) = splitWanteds unsolved
- (ambigs, others) = partition is_ambiguous (bagToList flats)
- ; groupErrs (reportFlat ctxt) others
- ; mapBagM_ (reportTidyImplic ctxt) implics
- ; ifErrsM (return ()) $
+ = do { let (flats, implics) = splitWanteds unsolved
+ (ambigs, non_ambigs) = partition is_ambiguous (bagToList flats)
+ (tv_eqs, others) = partition is_tv_eq non_ambigs
+
+ ; groupErrs (reportEqErrs ctxt) tv_eqs
+ ; when (null tv_eqs) $ groupErrs (reportFlat ctxt) others
+ ; when (null tv_eqs) $ mapBagM_ (reportTidyImplic ctxt) implics
+
-- Only report ambiguity if no other errors happened
-- See Note [Avoiding spurious errors]
+ ; when (isEmptyBag implics && null non_ambigs) $
reportAmbigErrs ctxt skols ambigs }
where
skols = foldr (unionVarSet . ic_skols) emptyVarSet (cec_encl ctxt)
+ -- Report equalities of form (a~ty) first. They are usually
+ -- skolem-equalities, and they cause confusing knock-on
+ -- effects in other errors; see test T4093b.
+ is_tv_eq c | EqPred ty1 ty2 <- wantedEvVarPred c
+ = tcIsTyVarTy ty1 || tcIsTyVarTy ty2
+ | otherwise = False
+
-- Treat it as "ambiguous" if
-- (a) it is a class constraint
-- (b) it constrains only type variables