Commit 8fd5e9fb authored by Tom Niget's avatar Tom Niget

thing

parent 95b8479f
...@@ -59,6 +59,7 @@ class str: ...@@ -59,6 +59,7 @@ class str:
def __contains__(self, item: Self) -> bool: ... def __contains__(self, item: Self) -> bool: ...
assert len("a") assert len("a")
assert not len(6)
class bytes: class bytes:
def decode(self, encoding: str) -> str: ... def decode(self, encoding: str) -> str: ...
...@@ -172,4 +173,6 @@ assert not __test_type().test_opt() ...@@ -172,4 +173,6 @@ assert not __test_type().test_opt()
def exit(code: int | None = None) -> None: ... def exit(code: int | None = None) -> None: ...
class Exception: class Exception:
def __init__(self, message: str) -> None: ... def __init__(self, message: str) -> None: ...
\ No newline at end of file
assert next([])
\ No newline at end of file
...@@ -8,7 +8,7 @@ from transpiler.phases.typing.common import ScoperVisitor, get_iter, get_next, i ...@@ -8,7 +8,7 @@ from transpiler.phases.typing.common import ScoperVisitor, get_iter, get_next, i
from transpiler.phases.typing.exceptions import ArgumentCountMismatchError, TypeMismatchKind, TypeMismatchError from transpiler.phases.typing.exceptions import ArgumentCountMismatchError, TypeMismatchKind, TypeMismatchError
from transpiler.phases.typing.types import BaseType, TY_STR, TY_BOOL, TY_INT, TY_COMPLEX, TY_FLOAT, TY_NONE, \ from transpiler.phases.typing.types import BaseType, TY_STR, TY_BOOL, TY_INT, TY_COMPLEX, TY_FLOAT, TY_NONE, \
ClassTypeType, ResolvedConcreteType, GenericType, CallableInstanceType, TY_LIST, TY_SET, TY_DICT, RuntimeValue, \ ClassTypeType, ResolvedConcreteType, GenericType, CallableInstanceType, TY_LIST, TY_SET, TY_DICT, RuntimeValue, \
TypeVariable, TY_LAMBDA, TypeListType, MethodType TypeVariable, TY_LAMBDA, TypeListType, MethodType, TY_TUPLE
from transpiler.phases.typing.scope import ScopeKind, VarDecl, VarKind from transpiler.phases.typing.scope import ScopeKind, VarDecl, VarKind
from transpiler.utils import linenodata from transpiler.utils import linenodata
...@@ -52,7 +52,7 @@ class ScoperExprVisitor(ScoperVisitor): ...@@ -52,7 +52,7 @@ class ScoperExprVisitor(ScoperVisitor):
return res return res
def visit_Tuple(self, node: ast.Tuple) -> BaseType: def visit_Tuple(self, node: ast.Tuple) -> BaseType:
return TupleType(*[self.visit(e) for e in node.elts]) return TY_TUPLE.instantiate_(*[self.visit(e) for e in node.elts])
def visit_Slice(self, node: ast.Slice) -> BaseType: def visit_Slice(self, node: ast.Slice) -> BaseType:
for n in ("lower", "upper", "step"): for n in ("lower", "upper", "step"):
......
...@@ -501,7 +501,7 @@ class CallableInstanceType(GenericInstanceType, MethodType): ...@@ -501,7 +501,7 @@ class CallableInstanceType(GenericInstanceType, MethodType):
) )
def __str__(self): def __str__(self):
return f"({", ".join(map(str, self.parameters + ([", *args"] if self.is_variadic else [])))}) -> {self.return_type}" return f"({", ".join(map(str, self.parameters + (["*args"] if self.is_variadic else [])))}) -> {self.return_type}"
def try_assign_internal(self, other: BaseType) -> bool: def try_assign_internal(self, other: BaseType) -> bool:
if not isinstance(other, CallableInstanceType): if not isinstance(other, CallableInstanceType):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment