[commit: ghc] ghc-8.0: Improve error message suppression (0e2b99a)

git at git.haskell.org git at git.haskell.org
Thu Feb 18 12:03:13 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/0e2b99affd07d8b46eb2f9f5b130a3a4c450358c/ghc

>---------------------------------------------------------------

commit 0e2b99affd07d8b46eb2f9f5b130a3a4c450358c
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Feb 15 08:39:23 2016 +0000

    Improve error message suppression
    
    TcErrors has a system for suppressing some type errors if a more
    serious one occurs.  But there was a crucial missing case, which
    sometimes resulted in a cascade of irrelevant errors overwhelming
    the actual cause. This was Trac #11541.
    
    The fix is simple.  Worth merging to 8.0
    
    (cherry picked from commit 18cd712427182e76d38047860ee3e26799bc3fe2)


>---------------------------------------------------------------

0e2b99affd07d8b46eb2f9f5b130a3a4c450358c
 compiler/typecheck/TcErrors.hs                        | 19 ++++++++++++-------
 .../rename/should_fail/RnStaticPointersFail02.stderr  |  6 ------
 testsuite/tests/rename/should_fail/mc14.stderr        | 14 --------------
 .../tests/typecheck/should_compile/T11254.stderr      | 10 ----------
 testsuite/tests/typecheck/should_fail/mc22.stderr     | 12 ------------
 testsuite/tests/typecheck/should_fail/mc25.stderr     | 11 -----------
 6 files changed, 12 insertions(+), 60 deletions(-)

diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs
index d447906..1985147 100644
--- a/compiler/typecheck/TcErrors.hs
+++ b/compiler/typecheck/TcErrors.hs
@@ -307,14 +307,19 @@ reportImplic ctxt implic@(Implic { ic_skols = tvs, ic_given = given
                      , ic_info  = info' }
     ctxt' = ctxt { cec_tidy     = env1
                  , cec_encl     = implic' : cec_encl ctxt
-                 , cec_suppress = insoluble  -- Suppress inessential errors if there
-                                             -- are are insolubles anywhere in the
-                                             -- tree rooted here
+
+                 , cec_suppress = insoluble || cec_suppress ctxt
+                      -- Suppress inessential errors if there
+                      -- are are insolubles anywhere in the
+                      -- tree rooted here, or we've come across
+                      -- a suppress-worthy constraint higher up (Trac #11541)
+
                  , cec_binds    = cec_binds ctxt *> m_evb }
-                                  -- if cec_binds ctxt is Nothing, that means
-                                  -- we're reporting *all* errors. Don't change
-                                  -- that behavior just because we're going into
-                                  -- an implication.
+                      -- If cec_binds ctxt is Nothing, that means
+                      -- we're reporting *all* errors. Don't change
+                      -- that behavior just because we're going into
+                      -- an implication.
+
     dead_givens = case status of
                     IC_Solved { ics_dead = dead } -> dead
                     _                             -> []
diff --git a/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr b/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr
index e596a51..b34f435 100644
--- a/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr
+++ b/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr
@@ -1,9 +1,3 @@
 
-RnStaticPointersFail02.hs:5:5: error:
-    • No instance for (Data.Typeable.Internal.Typeable t0)
-        arising from a static form
-    • In the expression: static T
-      In an equation for ‘f’: f = static T
-
 RnStaticPointersFail02.hs:5:12: error:
     Data constructor not in scope: T
diff --git a/testsuite/tests/rename/should_fail/mc14.stderr b/testsuite/tests/rename/should_fail/mc14.stderr
index bc7b7df..4182c8f 100644
--- a/testsuite/tests/rename/should_fail/mc14.stderr
+++ b/testsuite/tests/rename/should_fail/mc14.stderr
@@ -1,16 +1,2 @@
 
-mc14.hs:14:16: error:
-    Ambiguous type variable ‘t0’ arising from a use of ‘fmap’
-    prevents the constraint ‘(Functor t0)’ from being solved.
-    Probable fix: use a type annotation to specify what ‘t0’ should be.
-    These potential instances exist:
-      instance Functor IO -- Defined in ‘GHC.Base’
-      instance Functor Maybe -- Defined in ‘GHC.Base’
-      instance Functor ((->) r) -- Defined in ‘GHC.Base’
-      ...plus two others
-      (use -fprint-potential-instances to see them all)
-    In the expression: fmap
-    In a stmt of a monad comprehension: then group using f
-    In the expression: [() | f <- functions, then group using f]
-
 mc14.hs:14:49: error: Variable not in scope: f :: [a] -> m (t0 a)
diff --git a/testsuite/tests/typecheck/should_compile/T11254.stderr b/testsuite/tests/typecheck/should_compile/T11254.stderr
index 25cd751..692c72f 100644
--- a/testsuite/tests/typecheck/should_compile/T11254.stderr
+++ b/testsuite/tests/typecheck/should_compile/T11254.stderr
@@ -4,16 +4,6 @@ T11254.hs:16:10: warning:
         arising from the superclasses of an instance declaration
     • In the instance declaration for ‘ID Rational’
 
-T11254.hs:16:10: warning:
-    • No instance for (Fractional Int)
-        arising from the superclasses of an instance declaration
-    • In the instance declaration for ‘ID Rational’
-
-T11254.hs:16:10: warning:
-    • No instance for (ID Int)
-        arising from the superclasses of an instance declaration
-    • In the instance declaration for ‘ID Rational’
-
 T11254.hs:18:12: warning:
     • Couldn't match type ‘GHC.Real.Ratio Integer’ with ‘Int’
       Expected type: Rational -> Frac Rational
diff --git a/testsuite/tests/typecheck/should_fail/mc22.stderr b/testsuite/tests/typecheck/should_fail/mc22.stderr
index 5e369d7..955ebe5 100644
--- a/testsuite/tests/typecheck/should_fail/mc22.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc22.stderr
@@ -1,16 +1,4 @@
 
-mc22.hs:9:9: error:
-    • No instance for (Functor t) arising from a use of ‘fmap’
-      Possible fix:
-        add (Functor t) to the context of
-          a type expected by the context:
-            (a -> b) -> t a -> t b
-          or the inferred type of foo :: [t [Char]]
-    • In the expression: fmap
-      In a stmt of a monad comprehension: then group using take 5
-      In the expression:
-        [x + 1 | x <- ["Hello", "World"], then group using take 5]
-
 mc22.hs:10:26: error:
     • Couldn't match type ‘a’ with ‘t a’
       ‘a’ is a rigid type variable bound by
diff --git a/testsuite/tests/typecheck/should_fail/mc25.stderr b/testsuite/tests/typecheck/should_fail/mc25.stderr
index 406f89e..7fdb6ff 100644
--- a/testsuite/tests/typecheck/should_fail/mc25.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc25.stderr
@@ -1,15 +1,4 @@
 
-mc25.hs:9:10: error:
-    • No instance for (Functor t1) arising from a use of ‘fmap’
-      Possible fix:
-        add (Functor t1) to the context of
-          a type expected by the context:
-            (a -> b) -> t1 a -> t1 b
-          or the inferred type of z :: [t1 t]
-    • In the expression: fmap
-      In a stmt of a monad comprehension: then group by x using take
-      In the expression: [x | x <- [1 .. 10], then group by x using take]
-
 mc25.hs:9:46: error:
     • Couldn't match type ‘a -> t’ with ‘Int’
       Expected type: (a -> t) -> [a] -> [t1 a]



More information about the ghc-commits mailing list