# Buggy code
def visit_forwardref_type(self, t: ForwardRef) -> None:
    self.indicator["forward"] = True
    if t.resolved is None:
        resolved = self.anal_type(t.unbound)
        t.resolve(resolved)


# Traceback (IndexError)
.\break_mypy.py:22: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.560
Traceback (most recent call last):
File "c:\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Anaconda3\Scripts\mypy.exe\__main__.py", line 9, in <module>
sys.exit(console_entry())
File "c:\anaconda3\lib\site-packages\mypy\__main__.py", line 7, in console_entry
main(None)
File "c:\anaconda3\lib\site-packages\mypy\main.py", line 66, in main
res = type_check_only(sources, bin_dir, options)
File "c:\anaconda3\lib\site-packages\mypy\main.py", line 119, in type_check_only
options=options)
File "c:\anaconda3\lib\site-packages\mypy\build.py", line 218, in build
graph = dispatch(sources, manager)
File "c:\anaconda3\lib\site-packages\mypy\build.py", line 1997, in dispatch
process_graph(graph, manager)
File "c:\anaconda3\lib\site-packages\mypy\build.py", line 2299, in process_graph
process_stale_scc(graph, scc, manager)
File "c:\anaconda3\lib\site-packages\mypy\build.py", line 2475, in process_stale_scc
graph[id].type_check_first_pass()
File "c:\anaconda3\lib\site-packages\mypy\build.py", line 1876, in type_check_first_pass
self.type_checker().check_first_pass()
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 196, in check_first_pass
self.accept(d)
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 286, in accept
stmt.accept(self)
File "c:\anaconda3\lib\site-packages\mypy\nodes.py", line 497, in accept
return visitor.visit_func_def(self)
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 534, in visit_func_def
self.check_func_item(defn, name=defn.name())
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 599, in check_func_item
self.check_func_def(defn, typ, name)
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 762, in check_func_def
self.accept(item.body)
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 286, in accept
stmt.accept(self)
File "c:\anaconda3\lib\site-packages\mypy\nodes.py", line 756, in accept
return visitor.visit_block(self)
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 1330, in visit_block
self.accept(s)
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 286, in accept
stmt.accept(self)
File "c:\anaconda3\lib\site-packages\mypy\nodes.py", line 770, in accept
return visitor.visit_expression_stmt(self)
File "c:\anaconda3\lib\site-packages\mypy\checker.py", line 2097, in visit_expression_stmt
self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
File "c:\anaconda3\lib\site-packages\mypy\checkexpr.py", line 2361, in accept
typ = self.visit_call_expr(node, allow_none_return=True)
File "c:\anaconda3\lib\site-packages\mypy\checkexpr.py", line 268, in visit_call_expr
ret_type = self.check_call_expr_with_callee_type(callee_type, e, fullname, object_type)
File "c:\anaconda3\lib\site-packages\mypy\checkexpr.py", line 505, in check_call_expr_with_callee_type
object_type=object_type)[0]
File "c:\anaconda3\lib\site-packages\mypy\checkexpr.py", line 611, in check_call
object_type=object_type)
File "c:\anaconda3\lib\site-packages\mypy\checkexpr.py", line 568, in check_call
callee, args, arg_kinds, formal_to_actual, context)
File "c:\anaconda3\lib\site-packages\mypy\checkexpr.py", line 823, in infer_function_type_arguments
inferred_args, context)
File "c:\anaconda3\lib\site-packages\mypy\checkexpr.py", line 877, in infer_function_type_arguments_pass2
callee_type, arg_types, arg_kinds, formal_to_actual)
File "c:\anaconda3\lib\site-packages\mypy\infer.py", line 31, in infer_function_type_arguments
callee_type, arg_types, arg_kinds, formal_to_actual)
File "c:\anaconda3\lib\site-packages\mypy\constraints.py", line 63, in infer_constraints_for_callable
SUPERTYPE_OF)
File "c:\anaconda3\lib\site-packages\mypy\constraints.py", line 174, in infer_constraints
return template.accept(ConstraintBuilderVisitor(actual, direction))
File "c:\anaconda3\lib\site-packages\mypy\types.py", line 739, in accept
return visitor.visit_callable_type(self)
File "c:\anaconda3\lib\site-packages\mypy\constraints.py", line 415, in visit_callable_type
res.extend(infer_constraints(t, a, neg_op(self.direction)))
File "c:\anaconda3\lib\site-packages\mypy\constraints.py", line 174, in infer_constraints
return template.accept(ConstraintBuilderVisitor(actual, direction))
File "c:\anaconda3\lib\site-packages\mypy\types.py", line 475, in accept
return visitor.visit_instance(self)
File "c:\anaconda3\lib\site-packages\mypy\constraints.py", line 326, in visit_instance
mapped.args[i], instance.args[i], self.direction))
IndexError: list index out of range
.\break_mypy.py:22: : note: use --pdb to drop into pdb

# Fixed code
def visit_forwardref_type(self, t: ForwardRef) -> None:
    self.indicator["forward"] = True
    if t.resolved is None:
        resolved = self.anal_type(t.unbound)
        t.resolve(resolved)
        assert t.resolved is not None
        t.resolved.accept(self)