git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #390. Disallow unification of unknowns during type class instance resolution.
3a724b9Phil Freeman
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
421-- Check that two types unify
421-- Check that two types unify
422--
422--
423unifiesWith :: Environment -> Type -> Type -> Bool
423unifiesWith :: Environment -> Type -> Type -> Bool
424−unifiesWith _ (TUnknown _) _ = True
425−unifiesWith _ _ (TUnknown _) = True
426unifiesWith _ (Skolem _ s1 _) (Skolem _ s2 _) | s1 == s2 = True
424unifiesWith _ (Skolem _ s1 _) (Skolem _ s2 _) | s1 == s2 = True
427unifiesWith _ (TypeVar v1) (TypeVar v2) | v1 == v2 = True
425unifiesWith _ (TypeVar v1) (TypeVar v2) | v1 == v2 = True
428unifiesWith _ (TypeConstructor c1) (TypeConstructor c2) | c1 == c2 = True
426unifiesWith _ (TypeConstructor c1) (TypeConstructor c2) | c1 == c2 = True