@@ -737,8 +737,13 @@ def typecheck_method_override(m1, m2, location):
737737 # TODO move to caller
738738 (_ , type1 ) = eval_type (t1 , a1 .site , location , global_scope )
739739 (_ , type2 ) = eval_type (t2 , a2 .site , location , global_scope )
740- if safe_realtype_unconst (type1 ).cmp (
741- safe_realtype_unconst (type2 )) != 0 :
740+ type1 = safe_realtype_unconst (type1 )
741+ type2 = safe_realtype_unconst (type2 )
742+
743+ ok = (type1 .cmp_fuzzy (type2 )
744+ if compat .lenient_typechecking in dml .globals .enabled_compat
745+ else type1 .cmp (type2 )) == 0
746+ if not ok :
742747 raise EMETH (a1 .site , a2 .site ,
743748 f"mismatching types in input argument { n1 } " )
744749
@@ -747,8 +752,12 @@ def typecheck_method_override(m1, m2, location):
747752 ((n1 , t1 ), (n2 , t2 )) = (a1 .args , a2 .args )
748753 (_ , type1 ) = eval_type (t1 , a1 .site , location , global_scope )
749754 (_ , type2 ) = eval_type (t2 , a2 .site , location , global_scope )
750- if safe_realtype_unconst (type1 ).cmp (
751- safe_realtype_unconst (type2 )) != 0 :
755+ type1 = safe_realtype_unconst (type1 )
756+ type2 = safe_realtype_unconst (type2 )
757+ ok = (type1 .cmp_fuzzy (type2 )
758+ if compat .lenient_typechecking in dml .globals .enabled_compat
759+ else type1 .cmp (type2 )) == 0
760+ if not ok :
752761 msg = "mismatching types in return value"
753762 if len (outp1 ) > 1 :
754763 msg += f" { i + 1 } "
0 commit comments