Skip to content

Conversation

@Graveflo
Copy link
Contributor

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.

if effectiveArgType.kind == tyObject:
if sameObjectTypes(f, effectiveArgType):
c.inheritancePenalty = 0
c.inheritancePenalty = if tfInheritable in f.flags: 0 else: -1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tfInheritable isn't always defined for objects with inheritance, but tfFinal is for objects without inheritance. Checking this instead should work.

@Araq Araq marked this pull request as ready for review September 20, 2024 12:53
@Araq Araq merged commit 37dba85 into nim-lang:devel Sep 20, 2024
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 37dba85

Hint: mm: orc; opt: speed; options: -d:release
174460 lines; 8.081s; 653.977MiB peakmem

metagn pushed a commit to metagn/Nim that referenced this pull request Sep 21, 2024
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]>
narimiran pushed a commit that referenced this pull request Sep 23, 2024
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 <[email protected]>
(cherry picked from commit 37dba85)
Araq pushed a commit that referenced this pull request Feb 19, 2025
Applies #24144 to the equivalent matches of generic types, and adds the
behavior to matches of generic invocations to generic invocations. Not
encountered in many cases so it's hard to come up with tests but an
example is the test code in #24688, the match to the generic body never
sets the inheritance penalty leaving it at -1, but the match to the
generic invocation sets it to 0 which matches worse, when it should set
it to -1 because the object does not participate in inheritance.
narimiran pushed a commit that referenced this pull request Mar 3, 2025
Applies #24144 to the equivalent matches of generic types, and adds the
behavior to matches of generic invocations to generic invocations. Not
encountered in many cases so it's hard to come up with tests but an
example is the test code in #24688, the match to the generic body never
sets the inheritance penalty leaving it at -1, but the match to the
generic invocation sets it to 0 which matches worse, when it should set
it to -1 because the object does not participate in inheritance.

(cherry picked from commit ebeef10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants