Some logic for function call inferring

This commit is contained in:
greg 2018-02-26 21:28:11 -08:00
parent ef9cd04605
commit 92e6830979
1 changed files with 12 additions and 1 deletions

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>),