[Issue 17029] New: [Reg 2.072] scope variable may not be returned

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Dec 24 19:43:22 PST 2016


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

          Issue ID: 17029
           Summary: [Reg 2.072] scope variable may not be returned
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: code at dawg.eu

cat > bug.d << CODE
struct Del
{
    void delegate() dg;
}

Del del(scope void delegate() dg)
{
    return Del(dg);
}
CODE
dmd -c bug

----
bug.d(8): Error: scope variable dg may not be returned
----

This broke at least https://github.com/DlangScience/dstats.

Before DIP1000 scope had 2 major use cases, prevent the compiler from
allocating closures on the GC heap and scope classes.
We must be careful to not just break existing code.

--


More information about the Digitalmars-d-bugs mailing list