www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14982] New: nogc inconsistency

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

          Issue ID: 14982
           Summary: nogc inconsistency
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

import std.algorithm, std.range;

auto foo(int[] a, immutable int b)  nogc //Fails
{
    return a.map!(x => x + b);
}

auto bar(R)(R a, immutable int b)  nogc //OK
{
    return a.map!(x => x + b);
}

auto baz(int[] a, immutable int b)  nogc //OK
{
    return bar(a, b);
}

Foo cannot be made  nogc:
Error: function nogctest.foo  nogc function allocates a closure with the GC

--
Aug 30 2015