return scope ref outlives the scope of the argument

Eugene Wissner belka at caraus.de
Tue Jun 25 07:32:58 UTC 2019


struct Container
{
}

static struct Inserter
{
     private Container* container;

     private this(return scope ref Container container) @trusted
     {
         this.container = &container;
     }

}

auto func()()
{
     Container container;
     return Inserter(container);
}

void main()
{
     static assert(!is(typeof(func!())));
}

The code above compiles with dmd 2.085, but not 2.086 (with 
-preview=dip1000). What am I doing wrong?


More information about the Digitalmars-d-learn mailing list