Skip to content

Commit

Permalink
Fix incorrect inheritance penalty for some objects (nim-lang#24144)
Browse files Browse the repository at this point in the history
This fixes a logic error in  nim-lang#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 <[email protected]>
  • Loading branch information
2 people authored and metagn committed Sep 21, 2024
1 parent c9158bd commit e2dfe24
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e2dfe24

Please sign in to comment.