feat(types): add name to generic type

This commit is contained in:
2026-06-08 18:21:40 +02:00
parent f3ec3606c2
commit 0cde53ac6e
2 changed files with 6 additions and 3 deletions

View File

@@ -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: ...

View File

@@ -66,6 +66,7 @@ class TypeVar:
@dataclass(frozen=True, kw_only=True)
class GenericType:
name: str
params: list[TypeVar]
body: Type