[scope] improve 'scope' and 'return' inference for delegates#6495
[scope] improve 'scope' and 'return' inference for delegates#6495andralex merged 1 commit intodlang:masterfrom
Conversation
3f655e2 to
5593d7e
Compare
test/fail_compilation/retscope.d
Outdated
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Does that mean those are implicitly convertible now ?
There was a problem hiding this comment.
yes - I had gotten them wrong before.
There was a problem hiding this comment.
No you didn't. The following snippet (rightfully) doesn't compile with master, but does with your P.R.:
struct Bar { int i; }
alias FunDG = Bar* delegate () @safe;
void main () @safe
{
Bar* b = getBar();
}
Bar* getBar () @safe
{
Bar b;
scope FunDG x = () return { return &b; };
return forward(x);
}
Bar* forward (scope FunDG escaper) @safe
{
return escaper();
}There was a problem hiding this comment.
You're right. Will fix.
There was a problem hiding this comment.
If FunDG itself is declared as delegate () scope then the error is diagnosed. So the trouble is adding scope on later. Will investigate.
|
Wrong base branch, must be |
cf01c6a to
8465acd
Compare
I did a separate one for stable: |
Close this one in this case. The fix will get into master automatically when @MartinNowak merges stable branch after 2.073.1 It was also not necessary to create an new PR - GitHub now allows to change different base branch when editing the PR. |
|
This needs to be reopened. This fix is much more complete, and is needed. |
|
Seems like this is a superset of #6497? Definitely separate the new changes into their own commit then, and it will be up to @MartinNowak how to sequence the merge. |
|
Well, maybe I should just redo it as a separate PR, to avoid confusion. I'll think about it. It would need #6497 merged into master, though. |
|
@MartinNowak doesn't need to sequence the merge. He can just merge it - I'll rebase this one when he does. |
|
Please rebase, stable change already in master since #6498. |
8465acd to
3bb119d
Compare
|
Rebase done. |
|
Currently blocked by dlang/druntime#1753 |
|
Looking at dlang/druntime#1753, this will be fairly unusable in practice. People have added scope to delegate parameters basically everywhere to avoid GC closure allocations, now requiring to pass a delegate that actually is scope will break lots of code. Let's please do this as a deprecation. |
|
@MartinNowak the changes to druntime are necessary because druntime is now compiled with -dip1000. This does not affect non-dip1000 builds. As the numerous druntime and phobos PRs I've submitted attest, compiling with -dip1000 will need changes here and there. There is no other way I can think of - and that's why it's behind a switch. The transition period will be a long one. It's turning out to be a bit tricky to get code to compile both with and without -dip1000, but it's worth the effort. |
I'm not sure I follow your comment. The issue in the linked P.R. seems to be about a |
|
The |
|
Auto-merge toggled on |
Let me be a bit clearer on my comment (#6495 (comment)). |
I don't see another way. It's taking me a while to work through Phobos on this, and sometimes the rat's nest of circular dependencies in there make things difficult. But the ends are worth it. (Heck, we're still working on making Phobos @safe!) It will be quite a while until we can make -dip1000 the default. |
Just make it a deprecation instead of an error, so that things can be adopted incrementally. |
|
Remaining unexpected test failure/diff. |
295665d to
00b642d
Compare
00b642d to
7dd10aa
Compare
|
Blocked by dlang/druntime#1762 |
No description provided.