www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17422] New: [scope] class reference not initialized as scope

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: bugzilla digitalmars.com
          Reporter: code dawg.eu

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.

--
May 23