Starting to make unify actually work

This commit is contained in:
greg 2017-10-10 04:38:59 -07:00
parent 47975cf8f6
commit 8d8e3cd565
1 changed files with 6 additions and 4 deletions

View File

@ -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))
}
}
}