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 issue 21255: Mangle aliased overload set passed to template alias parameter. #11740

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

FeepingCreature
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @FeepingCreature! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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 references

Auto-close Bugzilla Severity Description
21255 normal "overload alias ... forward declaration" when overload set of imported template functions is passed to alias template parameter

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#11740"

@UplinkCoder
Copy link
Member

UplinkCoder commented Sep 16, 2020 via email

Copy link
Member

@UplinkCoder UplinkCoder left a comment

Choose a reason for hiding this comment

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

Needs a better/longer commit message.

Try to explain the problem you are fixing to someone who only has a passing familiarity with DMD.

@FeepingCreature
Copy link
Contributor Author

FeepingCreature commented Sep 16, 2020

Commit changed to work differently.

The problem is that overload declarations are kind of "fake declarations" without many of the properties DMD expects from ordinary declarations. So when we try to mangle them we run into a cryptic "forward declaration" error arising from DMD thinking they're "default" linkage, because that's LINK.init, and then it errors with "forward declaration" for no reason I can discern, because DMD is an undocumented cryptic mess at the best of days. Anyways, there's already code for mangling an overload set; we just have to avoid crashing until we reach it.

So now the commit just bypasses the bit that checks for special cases in declarations, ie. pragma(mangle) and extern(C), because those have to be checked when the OverDeclaration mangler recurses back into the contained declarations.

tl;dr: OverDeclaration is not a real subtype of Declaration. Why? ¯\_(ツ)_/¯

@UplinkCoder
Copy link
Member

@FeepingCreature yes please put that into the commit message.

…ing specialcases for template parameters.

The problem is that overload declarations are kind of "fake declarations"
without many of the properties DMD expects from ordinary declarations. So
when we try to mangle them, DMD thinks they're "default" linkage, because
that's LINK.init, and then it errors with "forward declaration" because
I guess that can't happen normally?

Anyways, there's already code for mangling an overload set; we just have
to avoid crashing until we reach it.

So now the commit just bypasses the bit that checks for special cases in
declarations, ie. pragma(mangle) and extern(C).

Why doesn't the handler for Declaration do all this?

¯\_(ツ)_/¯
@FeepingCreature
Copy link
Contributor Author

(moved explanation to commit message)

Copy link
Member

@UplinkCoder UplinkCoder left a comment

Choose a reason for hiding this comment

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

I hope we won't regret this :)

@FeepingCreature
Copy link
Contributor Author

FeepingCreature commented Sep 16, 2020

Shouldn't. Afaict, this only triggers if dmd would crash anyways. OverDeclarations are never mangleable as declarations, because they never have valid LINKage.

In other words, there's no way we'll ever regret it. :)

@UplinkCoder
Copy link
Member

@FeepingCreature I hear you. Yeah it's not that big of a deal as long as changes in the future don't break that unstated invariant.

@dlang-bot dlang-bot merged commit 43e8152 into dlang:master Sep 16, 2020
@FeepingCreature FeepingCreature deleted the fix/issue21255 branch September 16, 2020 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants