[Issue 24208] [DIP1000] Nested function can escape scope parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 29 23:14:08 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24208
--- Comment #2 from Paul Backus <snarwin+bugzilla at gmail.com> ---
...or maybe the problem is that it's being incorrectly inferred as `scope`
instead of `return scope`.
Another example:
---
void main() @safe
{
int* escaped;
void escape1(int* p) @safe
{
escaped = p;
}
void escape2(scope int* p) @safe
{
escaped = p;
}
void escape3(return scope int* p) @safe
{
escaped = p;
}
int n;
escape1(&n); // no error
escape2(&n); // error
escape3(&n); // error
}
---
It's hard to tell what attributes the compiler is inferring here, but the
observed behavior is consistent with the hypothesis that `scope int* p` is
being inferred for `escape1`, and `return scope int* p` is being inferred for
both `escape2` and `escape3`.
--
More information about the Digitalmars-d-bugs
mailing list