diff --git a/compiler/Type/Constrain/Declaration.hs b/compiler/Type/Constrain/Declaration.hs index aa0c8fe..63f55c3 100644 --- a/compiler/Type/Constrain/Declaration.hs +++ b/compiler/Type/Constrain/Declaration.hs @@ -24,6 +24,7 @@ import Parse.Parser (parseProgram) import Type.Solve (solve) import qualified Type.State as TS import Control.Monad.State +import Transform.SortDefinitions as Sort test filePath = do src <- readFile filePath @@ -32,7 +33,9 @@ test filePath = do Right (Module _ _ _ decls) -> do env <- Env.initialEnvironment var <- T.flexibleVar - constraint <- TcExpr.constrain env (toExpr decls) (T.VarN var) + let expr = sortDefs (toExpr decls) + print $ pretty expr + constraint <- TcExpr.constrain env expr (T.VarN var) print =<< T.extraPretty constraint (env,_,_,errors) <- execStateT (solve constraint) TS.initialState forM (Map.toList env) $ \(n,t) -> do @@ -43,7 +46,7 @@ test filePath = do mapM_ print =<< sequence errors toExpr decls = - SL.none $ SE.Let (concatMap toDefs decls) (SL.none $ SE.Literal (SL.IntNum 0)) + SL.none $ SE.Let (concatMap toDefs decls) (SL.none $ SE.Literal (SL.IntNum 42)) toDefs :: Declaration t v -> [SE.Def t v] toDefs decl = diff --git a/tests/good/Soundness.elm b/tests/good/Soundness.elm new file mode 100644 index 0000000..b540bed --- /dev/null +++ b/tests/good/Soundness.elm @@ -0,0 +1,9 @@ + +trickyID x = let y = x in y + +quad f = twice (twice f) +twice f x = f (f x) + +n = quad (quad trickyID) 4 +c = twice trickyID 'a' +