www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17935] New: [scope] auto-generated destructor not scope aware

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

          Issue ID: 17935
           Summary: [scope] auto-generated destructor not scope aware
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P4
         Component: dmd
          Assignee: bugzilla digitalmars.com
          Reporter: code dawg.eu

cat > bug.d << CODE
struct ByChunk(IO)
{
 safe:
    ~this() scope
    {}

    ubyte[] buf;
    IO io;
}

struct IO
{
    ~this()  safe scope
    {}
}

///
 safe  nogc unittest
{
    ubyte[256] buf;
    auto chunks = ByChunk!IO(buf[], IO());
    chunks.__xdtor(); // auto-generated inclusive (fields and struct) dtor
}
CODE
dmd -c -dip1000 bug.d
----
bug.d(21): Error: scope variable `chunks` assigned to non-scope parameter
`this` calling bug.ByChunk!(IO).ByChunk.~this
bug.d(22): Error: scope variable `chunks` assigned to non-scope parameter
`this` calling bug.ByChunk!(IO).ByChunk.~this
----

Guess we should at best always attempt to infer scope for any generate method.

--
Oct 24 2017