Skip to content

Crash when __lt__ has a second argument #5347

Description

@srittau

Please consider the following stub file:

classFoo:
def__lt__(self, other: object, context: str= ...) ->bool: ...

Checking it with either mypy 0.610 or current HEAD (0.620+dev-b07f8f5bdaeb25fc4111c2a01276635123f1a293) with Python 3.7.0 (and other versions) results in the following crash:

srittau@moby:~$ mypy --show-traceback test.pyi test.pyi:2: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.620+dev-b07f8f5bdaeb25fc4111c2a01276635123f1a293
Traceback (most recent call last):
File "/home/srittau/.local/bin/mypy", line 11, in <module>
load_entry_point('mypy==0.620+dev.b07f8f5bdaeb25fc4111c2a01276635123f1a293', 'console_scripts', 'mypy')()
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/main.py", line 91, in main
res = type_check_only(sources, bin_dir, options, flush_errors, fscache) # noqa
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/main.py", line 148, in type_check_only
fscache=fscache)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 177, in build
flush_errors, fscache)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 350, in _build
graph = dispatch(sources, manager)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2560, in dispatch
process_graph(graph, manager)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2853, in process_graph
process_stale_scc(graph, scc, manager)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2976, in process_stale_scc
graph[id].type_check_first_pass()
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2151, in type_check_first_pass
self.type_checker().check_first_pass()
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 253, in check_first_pass
self.accept(d)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 352, in accept
stmt.accept(self)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/nodes.py", line 808, in accept
return visitor.visit_class_def(self)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 1368, in visit_class_def
self.accept(defn.defs)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 352, in accept
stmt.accept(self)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/nodes.py", line 873, in accept
return visitor.visit_block(self)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 1514, in visit_block
self.accept(s)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 352, in accept
stmt.accept(self)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/nodes.py", line 591, in accept
return visitor.visit_func_def(self)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 663, in visit_func_def
self._visit_func_def(defn)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 667, in _visit_func_def
self.check_func_item(defn, name=defn.name())
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 729, in check_func_item
self.check_func_def(defn, typ, name)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 779, in check_func_def
self.check_reverse_op_method(item, typ, name, defn)
File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 1006, in check_reverse_op_method
assert len(reverse_type.arg_types) == 2
AssertionError: test.pyi:2: : note: use --pdb to drop into pdb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions