Start handling function case

This commit is contained in:
greg 2018-05-21 20:57:51 -07:00
parent 887ba46b0b
commit d040d76bfa

View File

@ -242,12 +242,20 @@ impl<'a> Infer<'a> {
fn infer_declaration(&mut self, decl: &parsing::Declaration) -> InferResult<MonoType> {
use parsing::Declaration::*;
use parsing::Signature;
match decl {
Binding { name, expr, .. } => {
let tau: MonoType = self.infer_expression(&expr)?;
let sigma = self.generalize(tau);
self.env.extend(name, sigma);
},
FuncDecl(Signature { name, params, type_anno }, block) => {
//TODO fill in here
return Err(InferError::Custom(format!("This decl not yet supported")))
},
_ => return Err(InferError::Custom(format!("This decl not yet supported")))
}
Ok(MonoType::Const(TypeConst::Unit))