Skip to content

Commit

Permalink
Fixed BasicType checking during lowering to core
Browse files Browse the repository at this point in the history
  • Loading branch information
alcides committed Jan 15, 2025
1 parent b63afaf commit ad43130
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions aeon/sugar/lowering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit ad43130

Please sign in to comment.