Closed
Description
In certain circumstances the daemon will crash with an array out of bounds error when a type parameter is removed from a class:
[case testRemoveGeneric]
[file a.py]
from typing import Generic, TypeVar
T = TypeVar('T')
class A(Generic[T]): pass
[file a.py.2]
from typing import Generic, TypeVar
T = TypeVar('T')
class A: pass
[file b.py]
from a import A
from d import take
def foo() -> None:
take([A()])
[file d.py]
from typing import List
from a import A
def take(x: List[A]): pass
[builtins fixtures/list.pyi]
[out]
==
crashes with a traceback ending in
File "/home/msullivan/src/mypy/mypy/checkexpr.py", line 812, in check_callable_call
callee, args, arg_kinds, formal_to_actual, context)
File "/home/msullivan/src/mypy/mypy/checkexpr.py", line 1027, in infer_function_type_arguments
strict=self.chk.in_checked_function())
File "/home/msullivan/src/mypy/mypy/infer.py", line 31, in infer_function_type_arguments
callee_type, arg_types, arg_kinds, formal_to_actual)
File "/home/msullivan/src/mypy/mypy/constraints.py", line 63, in infer_constraints_for_callable
c = infer_constraints(callee.arg_types[i], actual_type, SUPERTYPE_OF)
File "/home/msullivan/src/mypy/mypy/constraints.py", line 140, in infer_constraints
return template.accept(ConstraintBuilderVisitor(actual, direction))
File "/home/msullivan/src/mypy/mypy/types.py", line 667, in accept
return visitor.visit_instance(self)
File "/home/msullivan/src/mypy/mypy/constraints.py", line 325, in visit_instance
if tvars[j].variance != CONTRAVARIANT: