Skip to content

Commit bc79ea1

Browse files
committed
[mypyc] Improve error message for multiple inheritance.
mypyc/mypyc#962
1 parent c246a52 commit bc79ea1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mypyc/irbuild/prepare.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ def prepare_class_def(
301301
# Set up the parent class
302302
bases = [mapper.type_to_ir[base.type] for base in info.bases if base.type in mapper.type_to_ir]
303303
if not all(c.is_trait for c in bases[1:]):
304-
errors.error("Non-trait bases must appear first in parent list", path, cdef.line)
304+
errors.error(
305+
"Multiple inheritance is not currently supported (except for traits)",
306+
path,
307+
cdef.line,
308+
)
305309
ir.traits = [c for c in bases if c.is_trait]
306310

307311
mro = []

mypyc/test-data/commandline.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class Trait2(Concrete2):
164164
class NonExt(Concrete1): # E: Non-extension classes may not inherit from extension classes
165165
pass
166166

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

170170
@decorator

0 commit comments

Comments
 (0)