Commit 18cd7124 authored by Simon Peyton Jones's avatar Simon Peyton Jones

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
parent 4bba19a5
......@@ -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
_ -> []
......
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
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)
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’
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)
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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment