[Issue 22270] [DIP1000] class does infer scope in methods when assigned to a scope variable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 3 18:31:52 UTC 2021


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

--- Comment #4 from João Lourenço <jlourenco5691 at gmail.com> ---
So, how can I achieve something like this while instantiating a class or struct
with scope in @safe code?

---
struct Bar
{
    int[] somePointerToRestrictThis;

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

struct Wrapper
{
        Bar* bar;
}

@safe
void main()
{
    scope bar = Bar();
    cast(void) bar.dummy;
}
---

--


More information about the Digitalmars-d-bugs mailing list