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

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

--

Reply via email to