#7558: Terrible error message when given and wanted are both insoluble
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
In fixing the ambiguity check I came across this tricky program
{{{
data T a b where
MkT :: (a~Maybe b) => a -> Maybe b -> T a b
f :: T a a -> Bool
f (MkT x y) = [x,y] `seq` True
}}}
We get an error message
{{{
Frozen2.hs:12:18:
Could not deduce (a ~ Maybe a)
from the context (a ~ Maybe a)
bound by a pattern with constructor
MkT :: forall a b. a ~ Maybe b => a -> Maybe b -> T a b,
in an equation for `f'
at Frozen2.hs:12:4-10
`a' is a rigid type variable bound by
the type signature for f :: T a a -> Bool at Frozen2.hs:11:6
Relevant bindings include
f :: T a a -> Bool (bound at Frozen2.hs:12:1)
x :: a (bound at Frozen2.hs:12:8)
y :: Maybe a (bound at Frozen2.hs:12:10)
In the expression: y
In the first argument of `seq', namely `[x, y]'
In the expression: [x, y] `seq` True
}}}
This error message is nonsense! It arises becuase the "insolubles" get
both a "given" insoluble `(a~T a)` and a "wanted" insoluble with the same
type.
This can also arise, rather more easily, with the new ambiguity check, via
an inaccessible context
{{{
foo :: forall a. (a ~ T a) => a -> a
}}}
It's a bit obscure, but it needs fixing.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7558>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs