www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16037] New: Closure allocation despite scope variable for

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

          Issue ID: 16037
           Summary: Closure allocation despite scope variable for ternary
                    operator / CondExp
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mathias.lang sociomantic.com
                CC: public dicebot.lv

The following allocates memory and thus does not compile:

```
void testXXX ()  nogc
{
    Object o;
    scope bool delegate (Object) alwaysFalse = (Object y) { return false; };
    scope c1 = o !is null ? (Object y) { return o is y; } : alwaysFalse;
}
```

```
alloc.d(1): Error: function alloc.testXXX is  nogc yet allocates closures with
the GC
alloc.d(5):        alloc.testXXX.__lambda2 closes over variable o at alloc.d(3)
```

--
May 17 2016