feat(checker): type check tuple instantiation in Midas

This commit is contained in:
2026-06-29 14:00:37 +02:00
parent 11be47fce3
commit a6a1075f91
2 changed files with 7 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ if TYPE_CHECKING:
BUILTIN_SUBTYPES: dict[str, set[str]] = {
"object": {"float", "list", "dict", "str"},
"object": {"float", "list", "dict", "str", "tuple"},
"float": {"int"},
"int": {"bool"},
}
@@ -32,6 +32,8 @@ def define_builtins(reg: TypesRegistry):
str = reg.define_type("str", BaseType(name="str"))
slice = reg.define_type("slice", BaseType(name="slice"))
tuple = reg.define_type("tuple", BaseType(name="tuple"))
list = reg.define_type(
"list",
GenericType(

View File

@@ -18,6 +18,7 @@ from midas.checker.types import (
OverloadedFunction,
Predicate,
TopType,
TupleType,
Type,
TypeVar,
UnknownType,
@@ -346,6 +347,9 @@ class TypesRegistry:
body=substitute_typevars(body, substitutions),
)
case BaseType(name="tuple"):
return TupleType(items=tuple(args))
case _:
raise ValueError(f"{type} is not a generic type")