Mercurial > lcfOS
diff python/c3/typecheck.py @ 170:4348da5ca307
Cleanup of ir dir
author | Windel Bouwman |
---|---|
date | Fri, 29 Mar 2013 17:33:17 +0100 |
parents | 49f1ab80d040 |
children | 46d62dadd61b |
line wrap: on
line diff
--- a/python/c3/typecheck.py Sat Mar 23 18:34:41 2013 +0100 +++ b/python/c3/typecheck.py Fri Mar 29 17:33:17 2013 +0100 @@ -61,12 +61,16 @@ elif type(sym) is Binop: if sym.op in ['+', '-', '*', '/']: if equalTypes(sym.a.typ, sym.b.typ): - sym.typ = sym.a.typ + if equalTypes(sym.a.typ, intType): + sym.typ = sym.a.typ + else: + self.diag.error('Can only add integers', sym.loc) + sym.typ = intType else: # assume void here? TODO: throw exception! sym.typ = intType self.diag.error('Types unequal', sym.loc) - elif sym.op in ['>', '<']: + elif sym.op in ['>', '<', '==', '<=', '>=']: sym.typ = boolType if not equalTypes(sym.a.typ, sym.b.typ): self.diag.error('Types unequal', sym.loc)