Terrible error message when given and wanted are both insoluble
|Reported by:||simonpj||Owned by:||simonpj|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||gadt/T7558||Blocked By:|
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.