@@ -674,8 +674,13 @@ def typecheck_method_override(m1, m2, location):
674
674
# TODO move to caller
675
675
(_ , type1 ) = eval_type (t1 , a1 .site , location , global_scope )
676
676
(_ , type2 ) = eval_type (t2 , a2 .site , location , global_scope )
677
- if safe_realtype_unconst (type1 ).cmp (
678
- safe_realtype_unconst (type2 )) != 0 :
677
+ type1 = safe_realtype_unconst (type1 )
678
+ type2 = safe_realtype_unconst (type2 )
679
+
680
+ ok = (type1 .cmp_fuzzy (type2 )
681
+ if compat .lenient_typechecking in dml .globals .enabled_compat
682
+ else type1 .cmp (type2 )) == 0
683
+ if not ok :
679
684
raise EMETH (a1 .site , a2 .site ,
680
685
f"mismatching types in input argument { n1 } " )
681
686
@@ -684,8 +689,12 @@ def typecheck_method_override(m1, m2, location):
684
689
((n1 , t1 ), (n2 , t2 )) = (a1 .args , a2 .args )
685
690
(_ , type1 ) = eval_type (t1 , a1 .site , location , global_scope )
686
691
(_ , type2 ) = eval_type (t2 , a2 .site , location , global_scope )
687
- if safe_realtype_unconst (type1 ).cmp (
688
- safe_realtype_unconst (type2 )) != 0 :
692
+ type1 = safe_realtype_unconst (type1 )
693
+ type2 = safe_realtype_unconst (type2 )
694
+ ok = (type1 .cmp_fuzzy (type2 )
695
+ if compat .lenient_typechecking in dml .globals .enabled_compat
696
+ else type1 .cmp (type2 )) == 0
697
+ if not ok :
689
698
msg = "mismatching types in return value"
690
699
if len (outp1 ) > 1 :
691
700
msg += f" { i + 1 } "
0 commit comments