summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRyan McConnell <rammcconnell@gmail.com>2024-09-20 11:32:07 -0400
committerGitHub <noreply@github.com>2024-09-20 17:32:07 +0200
commit37dba853c9e2c41b445f1bbb7cfcf195773e6eee (patch)
tree278d5a1920c1568a8c9b806bf9891e0e54592e97
parent755307be61e4ee7b32c8354b2c303d04bdfc3a3e (diff)
downloadNim-37dba853c9e2c41b445f1bbb7cfcf195773e6eee.tar.gz
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 <rumpf_a@web.de>
-rw-r--r--compiler/sigmatch.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 96cbc6359..f09fd6b69 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: