-
-
Notifications
You must be signed in to change notification settings - Fork 610
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 15069 - nonsense struct template instantiations still compile #10613
Conversation
|
Thanks for your pull request and interest in making D better, @StianGulpen! 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 references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "stable + dmd#10613" |
|
Sorry I had modified the original test case. The problem is still there. |
|
I've found the real problem this time. An alias is created for each template parameter and this way the compiler thinks that it can be the enclosing template. |
|
ping for merge, this is good now. BTW there's also #10571. |
|
This doesn't look like a good solution to be fair. Sure it works, but having a boolean just to signal that this alias is not exactly like other aliases just means the abstraction was either wrong or incomplete to begin with. The fact that template parameters are aliases in the scope has been problematic from time to time. For example, most of the complexity in the C++ mangling code on POSIX comes from that. It's too minor to be worth a revert, but wanted to point it out in case you want to explore this further @StianGulpen . |
|
I think about a refactoring in master after the next patch release. Instead of the field, new classes (or at least one, derived from The idea is class TemplateParameterAlias : AliasDeclaration {}Honestly, knowing how things are generally well decomposed in DMDFE I was surprised that not utility exists allowing to make the difference, before my fix. |
|
well |
I originally tried to solve the problem at the root when I encountered it, using a similar approach, but aliases are removed as early as possible, so adding a new class won't help, and refactoring the code to prevent aliases being eliminated is a daunting task. And if you manage to get the job done, you're going to have to convince the reviewers that your hundreds of lines of refactoring are adding value. Another trivial example: void main () { bar(42); }
alias Foo = Object;
void bar (immutable(char)[] arg) {}
void bar (Foo arg) {}This outputs: hack.d(1): Error: none of the overloads of bar are callable using argument types (int), candidates are:
hack.d(3): hack.bar(string arg)
hack.d(4): hack.bar(Object arg)As you can see, the |
|
Your example is not related to template params being pulled in the scope as aliases. It rather illustrates a problem of a special case with unexpected side effects. Special cases are evils. |
Correct, but it is another symptom of the early elimination of
👍 |
|
Ok we agree finally. |
fix issue 15069 - nonsense struct template instantiations still compile merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com> Signed-off-by: Martin Krejcirik <mk@krej.cz>
No description provided.