Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect inheritance penalty for some objects #24144

Merged
merged 3 commits into from
Sep 20, 2024

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.

@@ -1528,7 +1528,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 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.

compiler/sigmatch.nim Outdated Show resolved Hide resolved
@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
19 checks passed
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)
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