-
-
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 21209 - scope attribute inference fails on foreach #12620
Conversation
|
Thanks for your pull request and interest in making D better, @dkorpel! 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 run digger -- build "master + dmd#12620" |
|
I still have to account for |
|
Well, |
fe31b31 to
95f3b1a
Compare
|
Does this also fix |
It only changes @safe:
void foo(T)(T s) {
static int x; x++; // force impure for issue 20150
foreach(node; s) {cast(void) node;}
}
struct S {
int* ptr;
int opApply(int delegate(scope S) @safe dg) scope {return 0;}
}
void main() {
scope S t;
foo(t);
} |
Pretty sure it just ignores it. Try to escape something from the |
Then it says "cannot pass argument |
|
Follow-up issue is here: https://issues.dlang.org/show_bug.cgi?id=21990 |
Scope inference fails as soon as you do:
A
foreachon an array gets rewritten to:This fix explicitly marks the temporary
__r83scope. It can't escape since it's hidden.This does not fix
foreachon an AliasSeq (which gets lowered to a special "unrolled" with the same temporary problem). If this fix gets accepted, I'll open a follow-up issue for that case, which is a bit harder since the temporary is not hidden, so you cannot just mark itscope.