From 5fb6450c2e9babd7d190a3efbd2846edd27c767d Mon Sep 17 00:00:00 2001 From: pimjager Date: Thu, 23 Jun 2016 09:12:55 +0200 Subject: [PATCH] small update type check --- gen.icl | 18 +++++++++--------- sem.icl | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gen.icl b/gen.icl index b6e22d6..25a4e6f 100644 --- a/gen.icl +++ b/gen.icl @@ -350,18 +350,18 @@ instance g Stmt where //and leaves the heap adress to write to on the stack followFs :: [FieldSelector] -> Gen() followFs [] = tell [] -followFs [FieldHd:fs] = tell [Instr "ldc" [Lit 1] "select hd" +followFs [FieldHd:fs] = tell [Instr "ldc" [Lit 1] "select hd" ,Instr "sub" [] "select hd"] - >>| followFs fs -followFs [FieldTl] = tell [] -followFs [FieldTl:fs] = tell [Instr "lda" [Lit 0] ""] - >>| followFs fs -followFs [FieldFst:fs] = tell [Instr "ldc" [Lit 1] "select fst" + >>| followFs fs +followFs [FieldTl] = tell [] +followFs [FieldTl:fs] = tell [Instr "lda" [Lit 0] ""] + >>| followFs fs +followFs [FieldFst:fs] = tell [Instr "ldc" [Lit 1] "select fst" ,Instr "sub" [] "select fst"] >>| followFs fs -followFs [FieldSnd:fs] = tell [Instr "lda" [Lit 0] ""] - >>| followFs fs -followFs [FieldSnd] = tell [] +followFs [FieldSnd:fs] = tell [Instr "lda" [Lit 0] ""] + >>| followFs fs +followFs [FieldSnd] = tell [] foldVarDecl :: Int VarDecl -> Gen Int foldVarDecl x (VarDecl _ mt k e) = g e diff --git a/sem.icl b/sem.icl index 8ca24cf..448c67e 100644 --- a/sem.icl +++ b/sem.icl @@ -202,7 +202,7 @@ unify (ta1->>ta2) (tb1->>tb2) = unify ta1 tb1 >>= \s1-> unify (subst s1 ta2) (subst s1 tb2) >>= \s2-> Right $ compose s2 s1 unify (TupleType (ta1,ta2)) (TupleType (tb1,tb2)) = unify ta1 tb1 >>= \s1-> - unify ta2 tb2 >>= \s2-> + unify (subst s1 ta2) (subst s1 tb2) >>= \s2-> Right $ compose s2 s1 unify (ListType t1) (ListType t2) = unify t1 t2 unify (FuncType t1) (FuncType t2) = unify t1 t2 -- 2.20.1