diff --git a/guppylang/definition/common.py b/guppylang/definition/common.py index 14c11880..73e8278b 100644 --- a/guppylang/definition/common.py +++ b/guppylang/definition/common.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, ClassVar, TypeAlias from hugr.build.dfg import DefinitionBuilder, OpVar +from hugr.ext import Package if TYPE_CHECKING: from guppylang.checker.core import Globals @@ -72,6 +73,10 @@ def description(self) -> str: a function, but got {description of this definition} instead". """ + def compile(self) -> Package: + assert self.id.module is not None + return self.id.module.compile() + class ParsableDef(Definition): """Abstract base class for raw definitions that still require parsing. diff --git a/tests/util.py b/tests/util.py index 8049f48b..3ada07b2 100644 --- a/tests/util.py +++ b/tests/util.py @@ -31,8 +31,8 @@ def compile_guppy(fn) -> Package: ), "`@compile_guppy` does not support extra arguments." module = GuppyModule("module") - guppylang.decorator.guppy(module)(fn) - return module.compile() + defn = guppylang.decorator.guppy(module)(fn) + return defn.compile() def dump_llvm(hugr: Hugr | Package):