From 2282d12a92a3cbee94817569bedc98bfb30dc1a8 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Fri, 24 May 2024 20:24:18 +0900 Subject: [PATCH] fix: unification bug --- crates/erg_compiler/context/unify.rs | 4 ++-- crates/erg_compiler/tests/infer.er | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/erg_compiler/context/unify.rs b/crates/erg_compiler/context/unify.rs index 39db7936f..9e3e68829 100644 --- a/crates/erg_compiler/context/unify.rs +++ b/crates/erg_compiler/context/unify.rs @@ -193,10 +193,10 @@ impl<'c, 'l, 'u, L: Locational> Unifier<'c, 'l, 'u, L> { // self.occur_inner(&sup_t, maybe_sup) })?; } - if let Some((_sub_t, sup_t)) = sup.get_subsup() { + if let Some((sub_t, sup_t)) = sup.get_subsup() { sup.do_avoiding_recursion(|| { // occur(?U, ?T(:> ?U or Y)) ==> OK - // self.occur_inner(maybe_sub, &sub_t)?; + self.occur_inner(maybe_sub, &sub_t)?; self.occur_inner(maybe_sub, &sup_t) })?; } diff --git a/crates/erg_compiler/tests/infer.er b/crates/erg_compiler/tests/infer.er index e4b4b749a..a4bcf1406 100644 --- a/crates/erg_compiler/tests/infer.er +++ b/crates/erg_compiler/tests/infer.er @@ -48,3 +48,10 @@ ff! x: Str or NoneType = do!: f0!() f0!() = print! "" f1! _: Str = f0!() + +arr = [1] +for! arr, (_,) => + if! True, do!: + if! True, do!: + if! True, do!: + todo()