-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Give D2-style operator overload priority over D1-style, reinstate the latter's deprecation #10725
Give D2-style operator overload priority over D1-style, reinstate the latter's deprecation #10725
Conversation
|
Thanks for your pull request, @Geod24! 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 "master + dmd#10725" |
See the changelog entry for the full rationale. TL;DR: It's more user friendly and sensical (although they were good reasons not to do it in the first place as well).
|
@don-clugston-sociomantic : Can you review ? Hope this will suit you. The only downside I can see is that the following is not supported: class DontDoThat {
int opAdd(int) {}
int opBinary(string op)(int) if (op == "-") { return 0; }
}
void main ()
{
scope o = new DontDoThat();
// This will now error out because the compiler does not consider `opAdd`,
// as it sees an `opBinary`... I don't think that's a big deal but you tell us.
o + 42;
} |
|
That looks great! From there, we can mark the D1 names as deprecated in our own code, so that we can flush out existing uses. Nice solution. |
I think that's good behaviour actually. Any code affected by that deserves to be broken. |
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.
LGTM. This is a good solution.
|
Nice! Note that I found even an alias works, and should be exactly equivalent to the original (no inlining necessary): class C
{
int *opIn_r(int x) { return null; }
alias opBinaryRight(string s : "in") = opIn_r;
}This should not error now, I would think (it did not error if the virtual call was not named |
|
Can we get this merged into stable, please? |
It was merged accidentally, see #10716 (comment)