From 92e68309791af0b30b68c3dbec1a72f58ab6c32d Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 26 Feb 2018 21:28:11 -0800 Subject: [PATCH] Some logic for function call inferring --- src/schala_lang/typechecking.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/schala_lang/typechecking.rs b/src/schala_lang/typechecking.rs index 46aeae5..362c22a 100644 --- a/src/schala_lang/typechecking.rs +++ b/src/schala_lang/typechecking.rs @@ -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),