diff --git a/guppylang/definition/common.py b/guppylang/definition/common.py index f3f5cb05..14c11880 100644 --- a/guppylang/definition/common.py +++ b/guppylang/definition/common.py @@ -39,6 +39,11 @@ class DefId: def fresh(cls, module: "GuppyModule | None" = None) -> "DefId": return DefId(next(cls._ids), module) + def __str__(self) -> str: + if self.module is None: + return f"DefId({self.id}, None)" + return f"DefId({self.id}, {self.module.name})" + @dataclass(frozen=True) class Definition(ABC): diff --git a/guppylang/tys/parsing.py b/guppylang/tys/parsing.py index 4006d2c8..2fd2a377 100644 --- a/guppylang/tys/parsing.py +++ b/guppylang/tys/parsing.py @@ -82,7 +82,7 @@ def _try_parse_defn(node: AstNode, globals: Globals) -> Definition | None: match node: case ast.Name(id=x): if x not in globals: - raise GuppyError("Unknown identifier", node) + raise GuppyError(f"Unknown identifier `{x}`", node) return globals[x] case ast.Attribute(value=ast.Name(id=module_name) as value, attr=x): if module_name not in globals: