From 4db3595d7c6eacfd3afd42caf090b9bb3abe2031 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 21 May 2018 00:06:31 -0700 Subject: [PATCH] More work on variables --- schala-lang/src/typechecking.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index 8e92e92..1c55016 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -129,6 +129,10 @@ impl TypeEnvironment { fn lookup(&self, name: &TypeName) -> Option { self.map.get(name).map(|x| x.clone()) } + + fn insert(&mut self, name: &TypeName, ty: PolyType) { + self.map.insert(name.clone(), ty); + } } pub struct TypeContext { @@ -180,7 +184,15 @@ impl<'a> Infer<'a> { Ok(ret) } - fn declaration(&mut self, expr: &parsing::Declaration) -> InferResult { + fn declaration(&mut self, decl: &parsing::Declaration) -> InferResult { + use parsing::Declaration::*; + match decl { + Binding { name, expr, .. } => { + let ty = self.anno_expression(&expr)?; + 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)) }