Bug Report
mypyc can fail with an internal AssertionError when it tries to generate __ne__ from an inherited __eq__.
This happens when the inherited method's declaration is available before its FuncIR body has been generated. One way to trigger this is with a package import cycle where __init__.py imports a child module before importing the subpackage that defines the base class.
To Reproduce
Add this test case to mypyc/test-data/run-multimodule.test:
[case testPackageCycleInheritedEq]
from other.other_child import Child
def make_child() -> Child:
return Child()
[file other/__init__.py]
from other.other_child import Child as Child
from other.other_subpkg import Base as Base
[file other/other_child.py]
from other.other_subpkg import Base
class Child(Base):
pass
[file other/other_subpkg/__init__.py]
from other.other_subpkg.other_base import Base as Base
[file other/other_subpkg/other_base.py]
class Base:
def __eq__(self, other: object) -> bool:
return True
[file driver.py]
from native import make_child
left = make_child()
right = make_child()
assert left == right
assert not (left != right)
Run:
python -m pytest -q mypyc/test/test_run.py -k testPackageCycleInheritedEq
Expected Behavior
mypyc should compile this successfully.
Since Child inherits Base.__eq__ but does not define __ne__, mypyc should be able to synthesize Child.__ne__ from the inherited __eq__ declaration.
Actual Behavior
mypyc fails with an internal assertion error while generating __ne__:
mypyc/irbuild/classdef.py:...: in gen_glue_ne_method
assert func_ir
AssertionError
Bug Report
mypyc can fail with an internal
AssertionErrorwhen it tries to generate__ne__from an inherited__eq__.This happens when the inherited method's declaration is available before its
FuncIRbody has been generated. One way to trigger this is with a package import cycle where__init__.pyimports a child module before importing the subpackage that defines the base class.To Reproduce
Add this test case to
mypyc/test-data/run-multimodule.test:Run:
Expected Behavior
mypyc should compile this successfully.
Since
ChildinheritsBase.__eq__but does not define__ne__, mypyc should be able to synthesizeChild.__ne__from the inherited__eq__declaration.Actual Behavior
mypyc fails with an internal assertion error while generating
__ne__: