Skip to content

Commit

Permalink
Allowing named types to unify if they are the same named type
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjay committed Oct 18, 2020
1 parent 767cad2 commit 163188d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tycheck/ty.rs
Expand Up @@ -115,6 +115,8 @@ impl UnifyValue for Ty {
(List(ty1), List(ty2)) => List(Box::new(Ty::unify_values(ty1, ty2)?)),
(Func(ty1), Func(ty2)) => Func(Box::new(FuncTy::unify_values(ty1, ty2)?)),

(&Named(def1), &Named(def2)) if def1 == def2 => Named(def1),

// Could return either one
(&TyVar(ty_var), TyVar(_)) => {
TyVar(ty_var)
Expand Down Expand Up @@ -147,6 +149,8 @@ impl Ty {
(List(ty1), List(ty2)) => List(Box::new(ty1.unify(*ty2, constraints)?)),
(Func(ty1), Func(ty2)) => Func(Box::new(ty1.unify(*ty2, constraints)?)),

(Named(def1), Named(def2)) if def1 == def2 => Named(def1),

(TyVar(ty_var1), TyVar(ty_var2)) => {
constraints.push(Constraint::TyVarsUnify {ty_var1, ty_var2});
// Could return either one
Expand Down

0 comments on commit 163188d

Please sign in to comment.