on master help sign in
Get variable reordering working for Declarations.
commit2b9853ce9b7b6892164484bb35dce1197f36ae43 authorEvan Czaplicki <evan@Evans-MacBook-Air.local> dateSat 13 Jul 2013, 13:44 (13 years ago) parentfe23c0e
2 files changed+14−2
compiler/Type/Constrain/Declaration.hs+5−2 tests/good/Soundness.elm+9
compiler/Type/Constrain/Declaration.hs+5−2
@@ -24,6 +24,7 @@ import Parse.Parser (parseProgram)
2424import Type.Solve (solve)
2525import qualified Type.State as TS
2626import Control.Monad.State
27+import Transform.SortDefinitions as Sort
2728
2829test filePath = do
2930 src <- readFile filePath
@@ -32,7 +33,9 @@ test filePath = do
3233 Right (Module _ _ _ decls) -> do
3334 env <- Env.initialEnvironment
3435 var <- T.flexibleVar
35− constraint <- TcExpr.constrain env (toExpr decls) (T.VarN var)
36+ let expr = sortDefs (toExpr decls)
37+ print $ pretty expr
38+ constraint <- TcExpr.constrain env expr (T.VarN var)
3639 print =<< T.extraPretty constraint
3740 (env,_,_,errors) <- execStateT (solve constraint) TS.initialState
3841 forM (Map.toList env) $ \(n,t) -> do
@@ -43,7 +46,7 @@ test filePath = do
4346 mapM_ print =<< sequence errors
4447
4548toExpr decls =
46− SL.none $ SE.Let (concatMap toDefs decls) (SL.none $ SE.Literal (SL.IntNum 0))
49+ SL.none $ SE.Let (concatMap toDefs decls) (SL.none $ SE.Literal (SL.IntNum 42))
4750
4851toDefs :: Declaration t v -> [SE.Def t v]
4952toDefs decl =
tests/good/Soundness.elmnew file+9
@@ -0,0 +1,9 @@
1+
2+trickyID x = let y = x in y
3+
4+quad f = twice (twice f)
5+twice f x = f (f x)
6+
7+n = quad (quad trickyID) 4
8+c = twice trickyID 'a'
9+