[Issue 22916] [dip1000] copy of ref return still treated as scope variable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 15 15:25:43 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22916

--- Comment #3 from Dennis <dkorpel at live.nl> ---
(In reply to Walter Bright from comment #1)
> Although
> the *ptr is not `scope`, because `scope` is not transitive, the compiler
> transfers the `scope` to the return value because it is told to.

No, my `return scope` annotation is correct. *ptr becomes `scope` again because
I return it by `ref`, which is effectively taking the address which cancels out
the dereference. If you mark `index` just `scope`, the compiler correctly
complains about `return *ptr`:

> Error: scope variable `this` may not be returned

--


More information about the Digitalmars-d-bugs mailing list