-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix incorrect inheritance penalty for some objects #24144
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
Conversation
compiler/sigmatch.nim
Outdated
| if effectiveArgType.kind == tyObject: | ||
| if sameObjectTypes(f, effectiveArgType): | ||
| c.inheritancePenalty = 0 | ||
| c.inheritancePenalty = if tfInheritable in f.flags: 0 else: -1 |
There was a problem hiding this comment.
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.
|
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
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]>
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)
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.
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)
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.