From f131105b509e571ba5f100a621e6add31a41d723 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 10 Oct 2017 04:38:59 -0700 Subject: [PATCH] Starting to make unify actually work --- src/schala_lang/type_check.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/schala_lang/type_check.rs b/src/schala_lang/type_check.rs index 6de0948..63b5eee 100644 --- a/src/schala_lang/type_check.rs +++ b/src/schala_lang/type_check.rs @@ -248,10 +248,12 @@ impl TypeContext { } fn unify(&mut self, t1: Type, t2: Type) -> TypeCheckResult { - if t1 == t2 { - Ok(t1.clone()) - } else { - Err(format!("Types {:?} and {:?} don't unify", t1, t2)) + use self::Type::*; + use self::TypeConst::*; + + match (&t1, &t2) { + (&TConst(ref c1), &TConst(ref c2)) if c1 == c2 => Ok(TConst(c1.clone())), + _ => Err(format!("Types {:?} and {:?} don't unify", t1, t2)) } } }