Slight refactoring

This commit is contained in:
greg 2017-10-10 02:32:02 -07:00
parent d9e8178a90
commit c68e09d89d
1 changed files with 6 additions and 4 deletions

View File

@ -169,15 +169,17 @@ impl TypeContext {
Ok(match (&expr.0, &expr.1) { Ok(match (&expr.0, &expr.1) {
(ref _t, &Some(ref anno)) => { (ref _t, &Some(ref anno)) => {
//TODO make this better, self.from_anno(anno)// TODO make this better,
self.from_anno(anno)
}, },
(&IntLiteral(_), _) => TConst(Integer), (&IntLiteral(_), _) => TConst(Integer),
(&FloatLiteral(_), _) => TConst(Float), (&FloatLiteral(_), _) => TConst(Float),
(&StringLiteral(_), _) => TConst(StringT), (&StringLiteral(_), _) => TConst(StringT),
(&BoolLiteral(_), _) => TConst(Boolean), (&BoolLiteral(_), _) => TConst(Boolean),
(&Variable(ref name), _) => self.lookup(name).map(|entry| entry.type_var) (&Variable(ref name), _) => {
.ok_or(format!("Couldn't find {}", name))?, self.lookup(name)
.map(|entry| entry.type_var)
.ok_or(format!("Couldn't find {}", name))?
},
(&BinExp(ref op, box ref lhs, box ref rhs), _) => { (&BinExp(ref op, box ref lhs, box ref rhs), _) => {
let _f_type = self.infer_op(op); let _f_type = self.infer_op(op);
let _lhs_type = self.infer(&lhs); let _lhs_type = self.infer(&lhs);