Starting to make unify actually work

This commit is contained in:
greg 2017-10-10 04:38:59 -07:00
parent 1089a33634
commit f131105b50

View File

@ -248,10 +248,12 @@ impl TypeContext {
} }
fn unify(&mut self, t1: Type, t2: Type) -> TypeCheckResult { fn unify(&mut self, t1: Type, t2: Type) -> TypeCheckResult {
if t1 == t2 { use self::Type::*;
Ok(t1.clone()) use self::TypeConst::*;
} else {
Err(format!("Types {:?} and {:?} don't unify", t1, t2)) 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))
} }
} }
} }