[Issue 20149] [DIP1000] Local data escapes `inout` method if not decorated with `return`
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Feb 14 09:42:37 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=20149
--- Comment #25 from Walter Bright <bugzilla at digitalmars.com> ---
A further simplified test case:
@safe:
struct S {
//inout(char)* slice() inout return /* gives correct error */
inout(char)* slice() inout /* no error */
{
return &buf;
}
char buf;
}
char* fun() {
S sb;
return sb.slice();
}
Note that if slice() were made as a static function, with sb passed by ref as
the first parameter, the compilation gives the correct error. Hence it's
related to the `this` being a special case.
--
More information about the Digitalmars-d-bugs
mailing list