[Issue 22916] [dip1000] copy of ref return still treated as scope variable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 26 18:07:51 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22916
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #5 from Walter Bright <bugzilla at digitalmars.com> ---
Looking at:
ref int* index() return scope {
return *ptr;
}
the compiler sees it as:
ref return scope T index();
which is interpreted as `ref` and `return scope` attached to `this`. `a` is
`this`. Since `a` is `scope`, the return value of `a.index()` is also `scope`.
This `scope` return value is then passed to `assign(int*)`, where the `int*`
parameter is not `scope`.
Assigning `scope` to `not scope` is an error and is correctly diagnosed by the
compiler.
--
More information about the Digitalmars-d-bugs
mailing list