KEMBAR78
Crash on reverse arithmetic method definitions with no arguments. · Issue #4241 · python/mypy · GitHub
Skip to content

Crash on reverse arithmetic method definitions with no arguments. #4241

@joshstaiger

Description

@joshstaiger

Run mypy (0.550) on the following code:

class A: ...

class B:
    def __rmul__(self) -> A: ...

This results in the traceback below.

This seems to occur with the other reverse arithmetic methods as well (radd, rtruediv, etc), but only if no arguments are specified in the method definition.

rmul_crash.py:4: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.550
Traceback (most recent call last):
  File "/Users/joshstaiger/anaconda/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/main.py", line 66, in main
    res = type_check_only(sources, bin_dir, options)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/main.py", line 119, in type_check_only
    options=options)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 214, in build
    graph = dispatch(sources, manager)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 1935, in dispatch
    process_graph(graph, manager)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 2199, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 2327, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 1836, in type_check_first_pass
    self.type_checker.check_first_pass()
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 196, in check_first_pass
    self.accept(d)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 283, in accept
    stmt.accept(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/nodes.py", line 690, in accept
    return visitor.visit_class_def(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 1185, in visit_class_def
    self.accept(defn.defs)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 283, in accept
    stmt.accept(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/nodes.py", line 750, in accept
    return visitor.visit_block(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 1305, in visit_block
    self.accept(s)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 283, in accept
    stmt.accept(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/nodes.py", line 496, in accept
    return visitor.visit_func_def(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 531, in visit_func_def
    self.check_func_item(defn, name=defn.name())
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 591, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 641, in check_func_def
    self.check_reverse_op_method(item, typ, name)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 841, in check_reverse_op_method
    arg_type = typ.arg_types[1]
IndexError: list index out of range
rmul_crash.py:4: : note: use --pdb to drop into pdb

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions