-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
Description
When you override a method and add an additional optional argument, mypyc crashes:
$ cat subcl.py
class X:
def f(self, y: int = False) -> None:
raise NotImplementedError
class Y(X):
def f(self, y: int = False, z: bool = True) -> None:
pass
$ mypyc subcl.py
Traceback (most recent call last):
File "build/setup.py", line 5, in <module>
ext_modules=mypycify([], ['subcl.py'], ),
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/build.py", line 377, in mypycify
cfiles, ops_text = generate_c(sources, options, lib_name,
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/build.py", line 254, in generate_c
ctext = emitmodule.compile_modules_to_c(result, module_names, shared_lib_name,
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/emitmodule.py", line 55, in compile_modules_to_c
literals, modules, errors = genops.build_ir(file_nodes, result.graph, result.types,
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 182, in build_ir
builder.visit_mypy_file(module)
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 876, in visit_mypy_file
self.accept(node)
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 3921, in accept
node.accept(self)
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/external/mypy/mypy/nodes.py", line 913, in accept
return visitor.visit_class_def(self)
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 1011, in visit_class_def
self.visit_method(cdef, get_func_def(stmt))
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 923, in visit_method
f = self.gen_glue_method(cls.method_decls[name].sig, func_ir, class_ir,
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 1205, in gen_glue_method
retval = self.call(target.decl, args, arg_kinds, arg_names, line)
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 2406, in call
arg_values_with_nones = self.native_args_to_positional(
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/genops.py", line 4637, in native_args_to_positional
formal_to_actual = map_actuals_to_formals(arg_kinds,
File "/Users/jelle/py/venvs/venv38/lib/python3.8/site-packages/mypyc/external/mypy/mypy/argmap.py", line 67, in map_actuals_to_formals
assert actual_kind == nodes.ARG_STAR2, (ai, actual_kinds, actual_names, formal_kinds, formal_names, actual_arg_type)
subcl.py:6: AssertionError: (1, [0, 1], ['self', 'y'], [0, 1, 1], ['self', 'y', 'z'], <function IRBuilder.native_args_to_positional.<locals>.<lambda> at 0x109980340>)
(Found this while working on python/mypy#6899. I added some stuff to the assertion to help me debug it. I'm running 3.8 but it also happens on 3.7 in https://travis-ci.org/python/mypy/jobs/541031294.)
It doesn't happen if the base class method doesn't take any positional argument. The arg kind is ARG_OPT, which map_actuals_to_formals() doesn't handle for some reason.
Metadata
Metadata
Assignees
Labels
No labels