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 20863 - Passing aggregate types by alias parameter drops qualifier #11320

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ntrel
Copy link
Contributor

@ntrel ntrel commented Jun 24, 2020

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @ntrel! 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
20863 normal Passing aggregate types into templates by alias drops qualifier

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#11320"

@ntrel ntrel marked this pull request as draft June 24, 2020 12:09
Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

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

Thanks!

@andralex
Copy link
Member

Looks like the autotester doesn't like it. Can you please take a look? E.g. https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid=4093573&isPull=true

ntrel added a commit to ntrel/phobos that referenced this pull request Jun 25, 2020
@ntrel
Copy link
Contributor Author

ntrel commented Jun 25, 2020

So I think dmd tests are now passing, but there is a wrong assert in Phobos's std.meta. This pull should fix that - is there a way of making the auto-tester merge that before testing this pull?

@UplinkCoder
Copy link
Member

This does look like a somewhat scary change.
It does change semantics in a subtle way.
Perhaps a revert switch should be there to be able to have a way out if this causes problems.

Copy link
Member

@ibuclaw ibuclaw left a comment

Choose a reason for hiding this comment

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

This is a breaking change that affects production/active projects.

e.g: https://buildkite.com/dlang/dmd/builds/14142#aabac065-d196-4981-bc2b-c796800aebe9/106-432

At the very least need to either deprecate the old behaviour, or pick the -transition or -revert route.

@ntrel
Copy link
Contributor Author

ntrel commented Jul 10, 2020

I added a revert switch, I don't think a deprecation can work here.

Copy link
Member

@ibuclaw ibuclaw left a comment

Choose a reason for hiding this comment

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

I added a revert switch, I don't think a deprecation can work here.

In the absence of a clear deprecation path then, cannot merge until...

  • All downstream projects covered by buildkite are patched and new releases made.
  • Changelog entry added saying what was fixed (demonstrating old and new behaviour, link to bugzilla issue), and that this is a breaking change.
  • A test for the new -revert switch has been added
  • C++ headers have been updated

ntrel added a commit to ntrel/vibe.d that referenced this pull request Jul 10, 2020
@ntrel
Copy link
Contributor Author

ntrel commented Jul 10, 2020

All downstream projects covered by buildkite are patched

That's only one, here's the fix:
vibe-d/vibe.d#2458

@UplinkCoder
Copy link
Member

Hmm I wonder how many production projects are accurately sampled by buildkite.
If a change to a buildkite tested projects has to be made, it is likely that a project which is not tested by buildkite also has to be changed.

@schveiguy
Copy link
Member

Given that most templates that had to deal with both symbols and types had to use two overloads (one with alias or one with a type), or use a tuple, I'd say the breakage is going to be pretty minimal.

I think the vibe.d case is a problem with the unittest possibly. The test was added 7 years ago, and the implementation was changed at that same commit (vibe-d/vibe.d@53b6947). I bet @mihails-strasuns just copied what the thing spit out for the unit test, not really intending it to be so inconsistent.

@schveiguy
Copy link
Member

schveiguy commented Jul 10, 2020

Note that this fixes a latent bug in NoDuplicates which treats things like const(Object) and Object to be the same.

Edit: of course, there is a bug report, I should have looked :)

https://issues.dlang.org/show_bug.cgi?id=11577

Geod24 pushed a commit to ntrel/vibe.d that referenced this pull request Dec 16, 2020
@@ -8108,8 +8109,13 @@ MATCH matchArg(TemplateParameter tp, Scope* sc, RootObject oarg, size_t i, Templ
if (sa)
{
if ((cast(Dsymbol)sa).isAggregateDeclaration())
{
// Don't lose type qualifiers
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why it lost the qualifiers in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

I don't want to merge this until I find out why there's a special case for aggregates (the bug doesn't appear for non-aggregates). I suspect the real flaw is elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Dsymbols doesn't have qualifiers and you get one as result of the getDsymbol call a little above.
We need to investigate why is it there and if it's possible to drop it, or just avoid getting a symbol if the type has any qualifier.

Copy link
Member

@WalterBright WalterBright left a comment

Choose a reason for hiding this comment

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

Need to find out why the qualifier was stripped only from aggregates in the first place.

@RazvanN7
Copy link
Contributor

RazvanN7 commented Sep 9, 2021

@WalterBright any progress on this? This is currently blocking work in phobos

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.

9 participants