-
-
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
Fix issue 12931: Make ambiguous qualifiers illegal on the LHS of a function #10757
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#10757" |
a666aed to
dfb4dab
Compare
|
This probably would have to be held off for a bit. The D1 operators, It would be great if we could go for longer-time support periods (e.g. LTS releases), but we'd probably need someone that is actually employed to do it. I will split off the changes in header generation though, as those can go on their own. |
|
Should this also include |
|
Hence, |
|
Then what does static class A { scope void toString(C, W)(scope ref W w) const { w.put(C('a')); } }
static class S { scope void toString(W)(scope ref W w) const { w.put("s"); } }
static class D { scope void toString(Dg)(scope Dg sink) const { sink("d"); } }
static class F { scope const(char)[] toString()() const return { return "f"; } }? |
|
It means the class A {
const(A) bar() const @safe { return this; }
}
const(A) bar () @safe
{
scope foo = new A;
auto x = foo.bar(); // Line 10
return x;
}Compiling with
You notice that the error is about the call to
The class itself does not know its allocation strategy. Nor does the caller know if the instance of
Which is, IMO the most correct error. Going back to your examples, what does |
Which is what I thought, hence this PR, no? |
The difference is you cannot make the return value |
Maybe, but it certainly looks like it. |
Actually it's the other way around. If you are going to do the 'body' deprecation in the next release (which I really think you shouldn't right now, but if you do) then you should do this at the same time. The
If you have no resources at all then the next best thing is to delay major breaking changes, and then do them all at once (eg no more than one such release per year). This means that the version with the breaking changes is a pseudo-LTS because it will be at least year until more breaking changes occur. |
4fad10b to
e64a5f3
Compare
…nction This has been a pain point for many D users for years, both new and old, as can be seen from the discussions on the issue. It is however a potentially disruptive deprecation. Note: The test for issue 5962 in test/runnable/xtest46.d has been removed as the issue was only present with prefix syntax.
|
Note that: all do the same thing. Breaking this for the first case would just introduce a weird inconsistency. |
|
Do you want |
|
No. I just see this change as pointlessly ticking people off. May I remind you of the proposal to remove static struct initializers :-) I didn't think anyone would complain about it, but sure as shootin', people who admitted never using them became dauntless champions of them. |
|
The difference is:
To me this is more similar to disallowing the C-style array syntax ( Note that if you feel strongly that we shouldn't pull this as-is, I can see two ways forward:
I was really on the fence about raising a DIP, but figured, since no-one seemed to disagree on this, I'd just go ahead with a PR. |
|
Let's just go with WONTFIX. We've got a mountain of more important things we should be doing. |
|
thank you |
This is an unfair characterization (as it was aimed at me). I took a look at the use cases that were provided and agreed with the people who were complaining that those use cases would look much worse. Before seeing the use cases, I was fully on board with deprecation of brace initialiation. One does not have to be a user of a feature to comprehend why it would be painful to remove for those who do use it. |
|
Perhaps it is a little unfair, and I apologize for that. But it is an obscure use case, just a few extra characters, and not the burden it was characterized as. Nevertheless, I'm leaning towards withdrawing support for the DIP. There's far more important work to be done than that DIP. |
|
Today, someone on my team asked this question:
The code in question: /// Interface for the node locator
public interface INodeLocator
{
public bool start ();
public string[] extractValues (string address, string[] paths);
}
public class NodeLocatorMock : INodeLocator
{
public bool start () {return true;} const @safe @nogc nothrow pure
public string[] extractValues (string address, string[] paths)
{
// Returns the same information regardless of the address
string[string] path_map =
[
"continent->names->en" : "Asia",
"country->names->en" : "South Korea",
"city->names->en" : "Seoul (Namdaemunno 5(o)-ga)",
"location->latitude" : "1.111",
"location->longitude" : "2.222",
];
return null;
}
}
int testmain()
{
return 0;
}There might be "more important things to do", but it doesn't mean this isn't important. |
With this argument one can close a lot of PRs... |
As noted before, dealing with this just creates another inconsistency and wart. Not in D, C, C++, Java, or any curly brace language I've ever heard of are attributes allowed after the closing } of a function definition. At some point, we're chasing rainbows by breaking one syntax to add another, and not really getting anywhere. But one can use this as a teaching moment. In D, C and C++, whitespace is not significant and is used only for aesthetics. Hence, if one is baffled by an error message on line X, it can be helpful to look at what is at the end of line X-1 or the start of line X+1. |
|
Well you mentioned that this would be "ticking people off". I think this change would be well received on the long run, even if it would create annoyance in the short term, just like implicit string concatenation did. If it's any indication, look at the reactions (👍) to the original post and your veto. As to inconsistencies, they already exists. TDPL (rightfully) boasts about void main ()
{
const int* ptr;
const(const(int)*) ptr2;
const(int*) ptr3;
}However, I can't count how many times I had to point out that the following are not the same: const(Object) get () nothrow;
const Object get () nothrow; |
Depends on dlang/phobos#7389 & dlang/phobos#7391I'll take a look at what is affected in Buildkite before we merge this.
Still needs a spec PR, and since it's a significant change, @WalterBright / @atilaneves ' approval.