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

--- Comment #7 from João Lourenço <[email protected]> ---
I was referring to:

```
scope bar1 = Bar();
auto  bar2 = Bar();
```

I thought `scope` only meant instantiating on the stack when used this way. But
I guess it also marks all fields as scope. If I understood correctly, the
instance `bar1` lifetime is the current scope and so are all its members, and
the instance `bar2` lifetime is the current scope but its members are assumed
to have infinite lifetime. And that's why if instantiate Bar normally without
scope I can do this in @safe code with dip1000:

```
struct Bar
{
    int[] arr;

    @safe Wrapper dummy() {
        Wrapper wrapper = { bar: &this };
        return wrapper;
    }
}

struct Wrapper { Bar* bar; }

@safe void main()
{
    auto bar = Bar();
    cast(void) bar.dummy;
}
```

--

Reply via email to