Skip to content

Commit

Permalink
[mypyc] Improve error message for multiple inheritance.
Browse files Browse the repository at this point in the history
  • Loading branch information
jab committed Dec 26, 2022
1 parent c246a52 commit 873fc67
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mypyc/irbuild/classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def transform_class_def(builder: IRBuilder, cdef: ClassDef) -> None:
# classes aren't necessarily populated yet at
# prepare_class_def time.
if any(ir.base_mro[i].base != ir.base_mro[i + 1] for i in range(len(ir.base_mro) - 1)):
builder.error("Non-trait MRO must be linear", cdef.line)
builder.error("Multiple inheritance is not supported (except for traits)", cdef.line)

if ir.allow_interpreted_subclasses:
for parent in ir.mro:
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/commandline.test
Original file line number Diff line number Diff line change
Expand Up @@ -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: Non-trait bases must appear first in parent list # E: Multiple inheritance is not supported (except for traits)
pass

@decorator
Expand Down

0 comments on commit 873fc67

Please sign in to comment.