Bug 17029 – [Reg 2.072] scope variable may not be returned
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-12-25T03:43:00Z
Last change time
2017-01-16T23:25:58Z
Keywords
safe
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2016-12-25T03:43:22Z
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.