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: [email protected]
Reporter: [email protected]
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.
--