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

          Issue ID: 17422
           Summary: [scope] class reference not initialized as scope
                    variable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

cat > bug.d << CODE
struct RC
{
    Object get() return scope @trusted
    {
        return cast(Object) &store[0];
    }

private:
    ubyte[__traits(classInstanceSize, Object)] store;
}

Object test() @safe
{
    RC rc;
    auto p = rc.get; // p must be inferred as scope variable, works for int*
    return p;
}
CODE
dmd -c bug -dip1000

Should raise an error but doesn't get catched by the compiler.

--

Reply via email to