Skip to content

Commit

Permalink
fix: type-instantiation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Sep 26, 2024
1 parent c024b8f commit 6c57ed6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions crates/erg_compiler/context/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ impl TyVarCache {
self.update_tyvar(inst, tv, ctx);
} else if let TyParam::FreeVar(_fv) = inst {
inst.destructive_link(&TyParam::t(tv.clone()));
} else {
unreachable!()
} else if let Ok(inst) = ctx.convert_tp_into_type(inst.clone()) {
self.update_tyvar(&inst, tv, ctx);
} else if DEBUG_MODE {
unreachable!("{name} / {inst} / {tv}");
}
} else {
self.tyvar_instances.insert(name.clone(), tv.clone());
Expand All @@ -201,8 +203,10 @@ impl TyVarCache {
self.update_tyvar(inst, tv, ctx);
} else if let TyParam::FreeVar(_fv) = inst {
inst.destructive_link(&TyParam::t(tv.clone()));
} else {
unreachable!()
} else if let Ok(inst) = ctx.convert_tp_into_type(inst.clone()) {
self.update_tyvar(&inst, tv, ctx);
} else if DEBUG_MODE {
unreachable!("{name} / {inst} / {tv}");
}
} else {
self.tyvar_instances.insert(name.clone(), tv.clone());
Expand Down Expand Up @@ -286,7 +290,9 @@ impl TyVarCache {
} else if let Some(inst) = self.tyvar_instances.get(name) {
if let Ok(tv) = <&Type>::try_from(tp) {
self.update_tyvar(inst, tv, ctx);
} else {
} else if let Ok(tv) = ctx.convert_tp_into_type(tp.clone()) {
self.update_tyvar(inst, &tv, ctx);
} else if DEBUG_MODE {
unreachable!("{name} / {inst} / {tp}");
}
} else {
Expand Down Expand Up @@ -321,8 +327,10 @@ impl TyVarCache {
} else if let Some(inst) = self.tyvar_instances.get(name) {
if let Ok(tv) = <&Type>::try_from(tp) {
self.update_tyvar(inst, tv, ctx);
} else {
unreachable!()
} else if let Ok(tv) = ctx.convert_tp_into_type(tp.clone()) {
self.update_tyvar(inst, &tv, ctx);
} else if DEBUG_MODE {
unreachable!("{name} / {inst} / {tp}")
}
} else {
self.typaram_instances.insert(name.clone(), tp.clone());
Expand Down

0 comments on commit 6c57ed6

Please sign in to comment.