Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mypyc] Improve error message for multiple inheritance.
Browse files Browse the repository at this point in the history
jab committed Dec 26, 2022
1 parent c246a52 commit bc79ea1
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mypyc/irbuild/prepare.py
Original file line number Diff line number Diff line change
@@ -301,7 +301,11 @@ def prepare_class_def(
# Set up the parent class
bases = [mapper.type_to_ir[base.type] for base in info.bases if base.type in mapper.type_to_ir]
if not all(c.is_trait for c in bases[1:]):
errors.error("Non-trait bases must appear first in parent list", path, cdef.line)
errors.error(
"Multiple inheritance is not currently supported (except for traits)",
path,
cdef.line,
)
ir.traits = [c for c in bases if c.is_trait]

mro = []
2 changes: 1 addition & 1 deletion mypyc/test-data/commandline.test
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ class Trait2(Concrete2):
class NonExt(Concrete1): # E: Non-extension classes may not inherit from extension classes
pass

class Nope(Trait1, Concrete2): # E: Non-trait bases must appear first in parent list # E: Non-trait MRO must be linear
class Nope(Trait1, Concrete2): # E: Multiple inheritance is not currently supported (except for traits) # E: Non-trait MRO must be linear
pass

@decorator

0 comments on commit bc79ea1

Please sign in to comment.