summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2016-02-15 08:39:23 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2016-02-15 08:47:30 +0000
commit18cd712427182e76d38047860ee3e26799bc3fe2 (patch)
treead170aafa1749598b4127f8f7499e0cc17287dd2
parent4bba19a56ddf98dc569878ea052e312487122d70 (diff)
downloadhaskell-18cd712427182e76d38047860ee3e26799bc3fe2.tar.gz
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
-rw-r--r--compiler/typecheck/TcErrors.hs19
-rw-r--r--testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr12
-rw-r--r--testsuite/tests/rename/should_fail/mc14.stderr18
-rw-r--r--testsuite/tests/typecheck/should_compile/T11254.stderr40
-rw-r--r--testsuite/tests/typecheck/should_fail/mc22.stderr42
-rw-r--r--testsuite/tests/typecheck/should_fail/mc25.stderr29
6 files changed, 56 insertions, 104 deletions
diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs
index 2cbf28d1b2..5f2c908849 100644
--- a/compiler/typecheck/TcErrors.hs
+++ b/compiler/typecheck/TcErrors.hs
@@ -304,14 +304,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 e596a51fb3..b34f4354b3 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
+
+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 bc7b7df291..4182c8fa8c 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)
+
+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 25cd751aa7..692c72f18d 100644
--- a/testsuite/tests/typecheck/should_compile/T11254.stderr
+++ b/testsuite/tests/typecheck/should_compile/T11254.stderr
@@ -1,25 +1,15 @@
-
-T11254.hs:16:10: warning:
- • Couldn't match type ‘Frac Int’ with ‘Int’
- 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
- Actual type: Rational -> Rational
- • When checking that instance signature for ‘embed’
- is more general than its signature in the class
- Instance sig: Rational -> Rational
- Class sig: Rational -> Frac Rational
- In the instance declaration for ‘ID Rational’
+
+T11254.hs:16:10: warning:
+ • Couldn't match type ‘Frac Int’ with ‘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
+ Actual type: Rational -> Rational
+ • When checking that instance signature for ‘embed’
+ is more general than its signature in the class
+ Instance sig: Rational -> Rational
+ Class sig: Rational -> Frac Rational
+ In the instance declaration for ‘ID Rational’
diff --git a/testsuite/tests/typecheck/should_fail/mc22.stderr b/testsuite/tests/typecheck/should_fail/mc22.stderr
index 5e369d7ffe..955ebe50fc 100644
--- a/testsuite/tests/typecheck/should_fail/mc22.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc22.stderr
@@ -1,27 +1,15 @@
-
-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
- a type expected by the context:
- forall a. [a] -> [t a]
- at mc22.hs:9:9
- Expected type: [a] -> [t a]
- Actual type: [t a] -> [t a]
- • In the expression: take 5
- 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]
- • Relevant bindings include
- foo :: [t [Char]] (bound at mc22.hs:8:1)
+
+mc22.hs:10:26: error:
+ • Couldn't match type ‘a’ with ‘t a’
+ ‘a’ is a rigid type variable bound by
+ a type expected by the context:
+ forall a. [a] -> [t a]
+ at mc22.hs:9:9
+ Expected type: [a] -> [t a]
+ Actual type: [t a] -> [t a]
+ • In the expression: take 5
+ 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]
+ • Relevant bindings include
+ foo :: [t [Char]] (bound at mc22.hs:8:1)
diff --git a/testsuite/tests/typecheck/should_fail/mc25.stderr b/testsuite/tests/typecheck/should_fail/mc25.stderr
index 406f89e719..7fdb6ff74c 100644
--- a/testsuite/tests/typecheck/should_fail/mc25.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc25.stderr
@@ -1,20 +1,9 @@
-
-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]
- Actual type: Int -> [t1 a] -> [t1 a]
- • In the expression: take
- 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]
- • Relevant bindings include z :: [t1 t] (bound at mc25.hs:9:1)
+
+mc25.hs:9:46: error:
+ • Couldn't match type ‘a -> t’ with ‘Int’
+ Expected type: (a -> t) -> [a] -> [t1 a]
+ Actual type: Int -> [t1 a] -> [t1 a]
+ • In the expression: take
+ 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]
+ • Relevant bindings include z :: [t1 t] (bound at mc25.hs:9:1)