Some logic for function call inferring

This commit is contained in:
greg 2018-02-26 21:28:11 -08:00
parent daa0062108
commit ce1d967f08

View File

@ -125,7 +125,18 @@ impl TypeContext {
}
},
&Call { ref f, ref arguments } => {
Err(format!("Function type not yet implemented"))
let mut tf = self.infer(f)?;
for arg in arguments.iter() {
match tf {
Func(box t, box rest) => {
let t_arg = self.infer(arg)?;
self.unify(t, t_arg)?;
tf = rest;
},
other => return Err(format!("Function call failed to unify; last type: {:?}", other)),
}
}
Ok(tf)
},
/*
TupleLiteral(Vec<Expression>),