From afa03ab036fdc36e86306b193d017bfa9e65ea73 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Thu, 3 Oct 2024 23:18:39 +0900 Subject: [PATCH] fix: type variable bug --- crates/erg_compiler/ty/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/erg_compiler/ty/mod.rs b/crates/erg_compiler/ty/mod.rs index 284c23f3..9bad94dd 100644 --- a/crates/erg_compiler/ty/mod.rs +++ b/crates/erg_compiler/ty/mod.rs @@ -4172,6 +4172,12 @@ impl Type { Self::FreeVar(fv) if fv.is_linked() => fv.unwrap_linked().eliminate_subsup(target), Self::FreeVar(ref fv) if fv.constraint_is_sandwiched() => { let (sub, sup) = fv.get_subsup().unwrap(); + let sub = if sub.addr_eq(target) { + Type::Never + } else { + sub + }; + let sup = if sup.addr_eq(target) { Type::Obj } else { sup }; let sub = sub.eliminate_subsup(target); let sup = sup.eliminate_subsup(target); self.update_tyvar(sub, sup, None, false);