[Issue 12664] New: @nogc for lazy arguments too

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Apr 27 06:44:34 PDT 2014


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

          Issue ID: 12664
           Summary: @nogc for lazy arguments too
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc

(Issue understood with a little help from Dicebot.)

This compiles:


void foo(int delegate() @nogc x) @nogc {
    auto r = x();
}
void main() {
    foo(() => 1);
}



This too compiles, performing inference:

void foo(Deleg)(Deleg x) @nogc {
    auto r = x();
}
void main() {
    foo(() => 1);
}


But this code:


void foo(lazy int x) @nogc {
    auto r = x(); // Error
}
void main() {
    foo(1);
}


Gives with DMD 2.066alpha:

test.d(2,15): Error: @nogc function 'test.foo' cannot call non- at nogc delegate
'x'


I think the third program should compile.

--


More information about the Digitalmars-d-bugs mailing list