From e2dfe246434bc8336f68ffa6be08741f34867b42 Mon Sep 17 00:00:00 2001 From: Ryan McConnell Date: Fri, 20 Sep 2024 11:32:07 -0400 Subject: [PATCH] Fix incorrect inheritance penalty for some objects (#24144) This fixes a logic error in #23870 The inheritance penalty should be -1 if there is no inheritance relationship. Not sure how to write a test case for this one honestly. --------- Co-authored-by: Andreas Rumpf --- compiler/sigmatch.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 96cbc6359bd6d..f09fd6b69fe95 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1540,7 +1540,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, reduceToBase(a) if effectiveArgType.kind == tyObject: if sameObjectTypes(f, effectiveArgType): - c.inheritancePenalty = 0 + c.inheritancePenalty = if tfFinal in f.flags: -1 else: 0 result = isEqual # elif tfHasMeta in f.flags: result = recordRel(c, f, a) elif trIsOutParam notin flags: