Skip to content

Commit b7bd774

Browse files
committed
Add extra test cases from comments to document current behaviour
1 parent 585bcb9 commit b7bd774

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

pyrefly/lib/test/class_subtyping.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,39 @@ class Both(Foo, Bar): # E: Field `p` has inconsistent types inherited from multi
274274
...
275275
"#,
276276
);
277+
278+
testcase!(
279+
test_nested_multiple_inheritance_incompatible_field_without_override,
280+
r#"
281+
class A:
282+
x: int
283+
class B:
284+
x: str
285+
class C(A, B): # E: Field `x` has inconsistent types inherited from multiple base classes
286+
pass
287+
class D:
288+
x: int
289+
290+
# Here we repeat the error on E, despite the error already being reported in C.
291+
class E(C, D): # E: Field `x` has inconsistent types inherited from multiple base classes
292+
pass
293+
"#,
294+
);
295+
296+
testcase!(
297+
test_nested_multiple_inheritance_incompatible_field_with_override,
298+
r#"
299+
class A:
300+
x: int
301+
class B:
302+
x: str
303+
class C(A, B): # E: Field `x` has inconsistent types inherited from multiple base classes
304+
x: int # E: Class member `C.x` overrides parent class `B` in an inconsistent manner
305+
class D:
306+
x: int
307+
308+
# Here we still report the error on E, despite the field being overridden in C.
309+
class E(C, D): # E: Field `x` has inconsistent types inherited from multiple base classes
310+
pass
311+
"#,
312+
);

0 commit comments

Comments
 (0)