diff --git a/midas/checker/midas.py b/midas/checker/midas.py index a7ce36f..c55123f 100644 --- a/midas/checker/midas.py +++ b/midas/checker/midas.py @@ -73,11 +73,13 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[None], m.Type.Visitor[Type var = TypeVar(name=name, bound=bound) self._local_variables[name] = var params.append(var) + name: str = stmt.name.lexeme type: Type = stmt.type.accept(self) if len(params) != 0: - type = GenericType(params=params, body=type) - name: str = stmt.name.lexeme - self.types.define_type(name, AliasType(name=name, type=type)) + type = GenericType(name=name, params=params, body=type) + else: + type = AliasType(name=name, type=type) + self.types.define_type(name, type) self._local_variables.clear() def visit_property_stmt(self, stmt: m.PropertyStmt) -> None: ... diff --git a/midas/checker/types.py b/midas/checker/types.py index ee41e14..8c95134 100644 --- a/midas/checker/types.py +++ b/midas/checker/types.py @@ -66,6 +66,7 @@ class TypeVar: @dataclass(frozen=True, kw_only=True) class GenericType: + name: str params: list[TypeVar] body: Type