Some more type work
This commit is contained in:
parent
66c7bbeb07
commit
83752a1c74
@ -166,6 +166,12 @@ impl TypeContext {
|
|||||||
(&BoolLiteral(_), _) => Univ(UVar::Boolean),
|
(&BoolLiteral(_), _) => Univ(UVar::Boolean),
|
||||||
(&Variable(ref name), _) => self.lookup(name).map(|entry| entry.type_var)
|
(&Variable(ref name), _) => self.lookup(name).map(|entry| entry.type_var)
|
||||||
.ok_or(format!("Couldn't find {}", name))?,
|
.ok_or(format!("Couldn't find {}", name))?,
|
||||||
|
(&BinExp(ref op, box ref lhs, box ref rhs), _) => {
|
||||||
|
let _f_type = self.infer_op(op);
|
||||||
|
let _lhs_type = self.infer(&lhs);
|
||||||
|
let _rhs_type = self.infer(&rhs);
|
||||||
|
unimplemented!()
|
||||||
|
},
|
||||||
(&Call { ref f, ref arguments }, _) => {
|
(&Call { ref f, ref arguments }, _) => {
|
||||||
let f_type = self.infer(&*f)?;
|
let f_type = self.infer(&*f)?;
|
||||||
let arg_type = self.infer(arguments.get(0).unwrap())?; // TODO fix later
|
let arg_type = self.infer(arguments.get(0).unwrap())?; // TODO fix later
|
||||||
@ -181,6 +187,19 @@ impl TypeContext {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn infer_op(&mut self, _op: &Operation) -> TypeCheckResult {
|
||||||
|
use self::TypeVariable::*;
|
||||||
|
Ok(
|
||||||
|
Univ(UVar::Function(
|
||||||
|
Box::new(Univ(UVar::Integer)),
|
||||||
|
Box::new(Univ(UVar::Function(
|
||||||
|
Box::new(Univ(UVar::Integer)),
|
||||||
|
Box::new(Univ(UVar::Integer))
|
||||||
|
)))
|
||||||
|
))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn unify(&mut self, t1: &TypeVariable, t2: &TypeVariable) -> TypeCheckResult {
|
fn unify(&mut self, t1: &TypeVariable, t2: &TypeVariable) -> TypeCheckResult {
|
||||||
if t1 == t2 {
|
if t1 == t2 {
|
||||||
Ok(t1.clone())
|
Ok(t1.clone())
|
||||||
|
Loading…
Reference in New Issue
Block a user