-
-
Notifications
You must be signed in to change notification settings - Fork 608
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 23722 - Lambdas are mangled incorrectly when using multiple compi… #15343
Conversation
Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
@@ -0,0 +1,16 @@ | |||
// COMPILE_SEPARATELY: | |||
// EXTRA_SOURCES: imports/test23722b.d | |||
// REQUIRED_ARGS: -betterC |
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.
necessary?
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.
No
f537047
to
594ec85
Compare
594ec85
to
9100c13
Compare
@dkorpel I've rebased your PR to see how it fares on the CI nowadays. |
Not ready (yet):
|
Is this abandoned? Should I create a new PR? This is a quite nasty issue, can cause calling incorrect function at runtime. |
@dkorpel Do you plan to update this PR? |
Yes, rebases of old PRs are always welcome. Note that this one failed CI so will need some changes. |
I'll rebase this and take another look at the undefined reference problem |
Thanks a lot! I've also updated the bug. tl;dr: I believe this fix is a correct one, but the example in the bug triggers two separate issues, and the second one gets uncovered by this fix. |
Yes, perhaps the test case should have Edit: not sure that affects the test case actually |
Well, it's not an instantiation, so I think |
…lation units, resulting in incorrect code
9100c13
to
3706959
Compare
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.
Looks good. Please resolve as appropriate 3706959#r1239935088
Uh, unfortunately I don't think that's a full fix... It's a bit more complicated than that.
|
You're right. I recall unittests used to simply use a counter, which wouldn't be stable with separate compilation. Hashing the function body wouldn't work, because you can have multiple identical anonymous functions. The only thing I can think of is keeping track of a stack of instantation locations and combining all those until you get something unique. |
7d4d2b9
to
8a0e8fb
Compare
I think templates and mixins are covered, since they will have all the instantiations/mixins in the final symbol name, the only place there we really need to make lambda names based on Loc unique is I failed to make a really failing example to showcase the problem with making lambdas inside templates even more unique, probably that problem with missing symbols I saw is LDC specific... What I can get with DMD so far is only code duplication:
Yes, that's the idea! We don't need to track them, I think, since the parent scope name is already what we want. Also, just adding that directly to the lambda ident will work, but with a lot of duplication. D's symbols are already long enough ;) |
Meanwhile I'll merge this as a partial fix, making a note in the issue. |
…le compi… (dlang#15343)" This reverts commit a3abf11.
…lation units, resulting in incorrect code
The problem now is that
FuncExp
in analias
is emitted in neither compilation unit, resulting in an undefined reference error.