From 8dc34e4b49fd2850afe4216748eda636851df01a Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 23 Feb 2019 01:27:32 -0800 Subject: [PATCH] Fresh type var --- schala-lang/language/src/typechecking.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/schala-lang/language/src/typechecking.rs b/schala-lang/language/src/typechecking.rs index bbf134f..cf4523e 100644 --- a/schala-lang/language/src/typechecking.rs +++ b/schala-lang/language/src/typechecking.rs @@ -30,7 +30,7 @@ pub type TypeName = Rc; pub struct TypeContext<'a> { variable_map: ScopeStack<'a, Rc, Type>, unification_table: InPlaceUnificationTable, - //evar_count: u32 + type_var_count: usize, } /// `InferResult` is the monad in which type inference takes place. @@ -207,7 +207,7 @@ impl<'a> TypeContext<'a> { TypeContext { variable_map: ScopeStack::new(None), unification_table: UnificationTable::new(), - //evar_count: 0 + type_var_count: 0, } } @@ -372,6 +372,12 @@ impl<'a> TypeContext<'a> { (a, b) => TypeError::new(format!("{:?} and {:?} do not unify", a, b)), } } + + fn fresh_type_variable(&mut self) -> TypeVar { + let n = self.type_var_count; + self.type_var_count += 1; + TypeVar(n) + } } #[cfg(test)]