On Friday, 17 August 2018 at 13:39:29 UTC, Steven Schveighoffer wrote:
On 8/17/18 3:36 AM, Atila Neves wrote:
Here's a struct:
-----------------
// used to be scope int* ptr() { return ints; }
scope inout(int)* ptr() inout { return ints; }

Does scope apply to the return value or the `this` reference?


This reference. putting it like:

inout(int)* ptr() inout scope { return ints; }

...does not change anything.

Another thing it should AFAIK catch but doesn't:

import std.stdio;
@safe:

struct MyStruct {
    int* intP;
    this(int val) { intP = new int(val); }
    int* ptr() return scope { return intP; }
}


int *gInt;

void main() {
    auto s = MyStruct(10);
    gInt = s.ptr;
    writeln(*gInt);
}

Reply via email to