git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix type synonym issue #165
16f0260Phil Freeman
examples/passing/ObjectSynonym.pursnew file+15
@@ -0,0 +1,15 @@
1+module ObjectSynonym where
2+
3+type Inner = Number
4+
5+inner :: Inner
6+inner = 0
7+
8+type Outer = { inner :: Inner }
9+
10+outer :: Outer
11+outer = { inner: inner }
12+
13+module Main where
14+
15+main = Trace.trace "Done"
src/Language/PureScript/TypeChecker/Types.hs+8−1
@@ -814,7 +814,8 @@ check' v@(Var var) ty = do
814 Just moduleName <- checkCurrentModule <$> get
814 Just moduleName <- checkCurrentModule <$> get
815 ty1 <- lookupVariable moduleName var
815 ty1 <- lookupVariable moduleName var
816 repl <- replaceAllTypeSynonyms ty1
816 repl <- replaceAllTypeSynonyms ty1
817+ ty' <- replaceAllTypeSynonyms ty
817− v' <- subsumes (Just v) repl ty
818+ v' <- subsumes (Just v) repl ty'
818 case v' of
819 case v' of
819 Nothing -> throwError "Unable to check type subsumption"
820 Nothing -> throwError "Unable to check type subsumption"
820 Just v'' -> return v''
821 Just v'' -> return v''
@@ -973,6 +974,12 @@ subsumes' val (TypeApp (TypeApp f1 arg1) ret1) (TypeApp (TypeApp f2 arg2) ret2)
973 subsumes Nothing arg2 arg1
974 subsumes Nothing arg2 arg1
974 subsumes Nothing ret1 ret2
975 subsumes Nothing ret1 ret2
975 return val
976 return val
977+subsumes' val (SaturatedTypeSynonym name tyArgs) ty2 = do
978+ ty1 <- expandTypeSynonym name tyArgs
979+ subsumes val ty1 ty2
980+subsumes' val ty1 (SaturatedTypeSynonym name tyArgs) = do
981+ ty2 <- expandTypeSynonym name tyArgs
982+ subsumes val ty1 ty2
976subsumes' (Just val) (ConstrainedType constraints ty1) ty2 = do
983subsumes' (Just val) (ConstrainedType constraints ty1) ty2 = do
977 env <- getEnv
984 env <- getEnv
978 dicts <- getTypeClassDictionaries
985 dicts <- getTypeClassDictionaries