From ad43130481d5eb64b405d0ce93d9d0aba20c9228 Mon Sep 17 00:00:00 2001 From: Alcides Fonseca Date: Wed, 15 Jan 2025 10:57:16 +0000 Subject: [PATCH] Fixed BasicType checking during lowering to core --- aeon/sugar/lowering.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/aeon/sugar/lowering.py b/aeon/sugar/lowering.py index f29cfee..ffeff71 100644 --- a/aeon/sugar/lowering.py +++ b/aeon/sugar/lowering.py @@ -145,6 +145,16 @@ def liquefy( assert False +def basic_type(ty: Type) -> BaseType | TypeVar: + match ty: + case BaseType(_) | TypeVar(_): + return ty + case RefinedType(_, it, _): + return basic_type(it) + case _: + assert False, f"Unknown base type {ty}" + + def type_to_core( ty: SType, available_vars: list[tuple[str, BaseType | TypeVar]] | None = None @@ -165,9 +175,10 @@ def type_to_core( return TypeVar(name) case SAbstractionType(name, vty, rty): at = type_to_core(vty, available_vars) - assert isinstance(at, BaseType) or isinstance(at, TypeVar) + return AbstractionType( - name, at, type_to_core(rty, available_vars + [(name, at)])) + name, at, + type_to_core(rty, available_vars + [(name, basic_type(at))])) case STypePolymorphism(name, kind, rty): return TypePolymorphism(name, kind, type_to_core(rty, available_vars))