Fix #390. Disallow unification of unknowns during type class instance resolution.
commit3a724b9d5b230d54557c9dd5b59ba05d5bae3ce3
authorPhil Freeman <paf31@cantab.net>
dateFri 25 Apr 2014, 22:31 (13 years ago)
parenta125a18
examples/failing/UnifyInTypeInstanceLookup.pursnew file+17
@@ -0,0 +1,17 @@
1+module Main where
2+
3+data Z = Z
4+data S n = S n
5+
6+data T
7+data F
8+
9+class EQ x y b
10+instance eqT :: EQ x x T
11+instance eqF :: EQ x y F
12+
13+foreign import test :: forall a b. (EQ a b T) => a -> b -> a
14+
15+foreign import anyNat :: forall a. a
16+
17+test1 = test anyNat (S Z)
src/Language/PureScript/TypeChecker/Types.hs−2
@@ -421,8 +421,6 @@ pairwise p (x : xs) = all (p x) xs && pairwise p xs
421421-- Check that two types unify
422422--
423423unifiesWith :: Environment -> Type -> Type -> Bool
424−unifiesWith _ (TUnknown _) _ = True
425−unifiesWith _ _ (TUnknown _) = True
426424unifiesWith _ (Skolem _ s1 _) (Skolem _ s2 _) | s1 == s2 = True
427425unifiesWith _ (TypeVar v1) (TypeVar v2) | v1 == v2 = True
428426unifiesWith _ (TypeConstructor c1) (TypeConstructor c2) | c1 == c2 = True