]> ruin.nu Git - proglang.git/commitdiff
done?
authorMichael Andreen <harv@ruin.nu>
Fri, 24 Feb 2006 12:04:35 +0000 (12:04 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 24 Feb 2006 12:04:35 +0000 (12:04 +0000)
Typecheck.hs
examples/typeerror [new file with mode: 0644]

index 35ed382d11e00e572eb4094153101ba54a34453e..922264061337362de5dab48dcbdb8163b9bee8d4 100644 (file)
@@ -33,6 +33,9 @@ typeCheckExp EDefault = return NoType
 typeCheckExp (EPost i op) = do
        TInt <- typeCheckVar i
        return TInt
+typeCheckExp (ENeg e) = do
+       TInt <- typeCheckExp e
+       return TInt
 
 
 typeCheckVar :: (MonadState Types m) => Ident -> m Type 
@@ -59,11 +62,11 @@ typeCheckStm (SWhile e s) = do
        return NoType
 typeCheckStm (SDecl t i e) = do
        t2 <- typeCheckExp e
-       if t == t2 then do
+       if t == t2 || t2 == NoType then do
                m <- get
                put (insert i t m)
                return NoType
-               else fail $ "Illegal to assign an expression of type "++show t2++" to variable "++show i++" of type "++show t2
+               else fail $ "Illegal to assign an expression of type "++show t2++" to variable "++show i++" of type "++show t
 typeCheckStm (SPrint e) = do
        typeCheckExp e
        return NoType
diff --git a/examples/typeerror b/examples/typeerror
new file mode 100644 (file)
index 0000000..2f26aa5
--- /dev/null
@@ -0,0 +1 @@
+bool b = 1;