Skip to content

Overriding definition such as type alias in a subclass causes a crash #5425

Description

@Michael0x2a

The following program crashes on both mypy 0.620 and the latest version on master:

fromtypingimportAny, CallableclassParent:
foo=Callable[..., int] classChild(Parent):
deffoo(self, val: int) ->int:
returnval*2

(In this case, I meant to do foo: Callable[..., int].)

Here's the traceback:

test.py:13: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/
issues version: 0.630+dev-1222c9637b673bcca6218a943cd4b88b8749b0ad
Traceback (most recent call last):
File "C:\Python3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Michael\Dropbox\mypy\mypy\__main__.py", line 11, in <module>
main(None)
File "C:\Users\Michael\Dropbox\mypy\mypy\main.py", line 91, in main
res = type_check_only(sources, bin_dir, options, flush_errors, fscache) # noqa
File "C:\Users\Michael\Dropbox\mypy\mypy\main.py", line 148, in type_check_only
fscache=fscache)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 177, in build
flush_errors, fscache)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 350, in _build
graph = dispatch(sources, manager)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2572, in dispatch
process_graph(graph, manager)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2866, in process_graph
process_stale_scc(graph, scc, manager)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2989, in process_stale_scc
graph[id].type_check_first_pass()
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2162, in type_check_first_pass
self.type_checker().check_first_pass()
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 253, in check_first_pass
self.accept(d)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 352, in accept
stmt.accept(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\nodes.py", line 808, in accept
return visitor.visit_class_def(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1389, in visit_class_def
self.accept(defn.defs)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 352, in accept
stmt.accept(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\nodes.py", line 873, in accept
return visitor.visit_block(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1535, in visit_block
self.accept(s)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 352, in accept
stmt.accept(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\nodes.py", line 591, in accept
return visitor.visit_func_def(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 663, in visit_func_def
self._visit_func_def(defn)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 674, in _visit_func_def
self.check_method_override(defn)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1200, in check_method_override
self.check_method_or_accessor_override_for_base(defn, base)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1210, in check_method_or_accessor_override_for_base
self.check_method_override_for_base_with_name(defn, name, base)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1254, in check_method_override_for_base_with_name
assert False, str(base_attr.node)
AssertionError: <mypy.nodes.TypeAlias object at 0x000002139F12C588>
test.py:13: : note: use --pdb to drop into pdb

I did a cursory skim of the existing crash issues, but maybe this is already a known issue? If so, feel free to close.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions