Slight refactoring
This commit is contained in:
parent
e2a94280c2
commit
3e44bd3a18
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user