Unify var-var

This commit is contained in:
greg 2019-02-23 01:20:19 -08:00
parent 452f2ab188
commit 2cc3367666

View File

@ -365,7 +365,9 @@ impl<'a> TypeContext<'a> {
},
(a @ Var(_), b @ Const(_)) => self.unify(b, a),
(Var(v1), Var(v2)) => {
panic!()
self.unification_table.unify_var_var(v1.clone(), v2.clone())
.or_else(|_| TypeError::new(format!("Two type variables {:?} and {:?} couldn't unify", v1, v2)))?;
Ok(Var(v1.clone())) //arbitrary decision I think
},
(a, b) => TypeError::new(format!("{:?} and {:?} do not unify", a, b)),
}