www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17934] New: [scope] scopeness entrypoint for


          Issue ID: 17934
           Summary: [scope] scopeness entrypoint for unique/ref-counted
           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
import core.stdc.stdlib;

struct List
    Elem front()  safe return scope
        return Elem(data);

    ~this()  trusted scope
        data = null;

     disable this(this);

    void* data;

struct Elem
    void* data;

  There seems to be now way to write this functions so
  that the compiler infers the return value as scope.
List list()  trusted
    return List(malloc(1));

void test()  safe
    Elem elem;
        //scope l = list(); // works with explicit scope
        auto l = list(); // not inferred as scope
        elem = l.front; // escapes, b/c l isn't scoped
dmd -c -dip1000 bug.d

Repeatedly ending up with this problem. It doesn't seem possible to contain
allocated data, as there is now way to enforce that the call-site uses a scope

Oct 24 2017