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

Paul Backus <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #11 from Paul Backus <[email protected]> ---
One workaround for this is to pass the value to a callback as a scope
parameter, rather than returning it:

---
void withList(alias callback)()
{
    scope l = (() @trusted => List(malloc(1)))();
    callback(l);
}

void test() @safe
{
    Elem elem;
    withList!((scope ref l) {
        elem = l.front; // scope variable `l` assigned to `elem` with longer
lifetime
    });
}
---

--

Reply via email to