Thread overview
[Issue 12808] Small amount of escape analysis to allow more @nogc functions
Dec 08, 2021
Stanislav Blinov
Dec 17, 2022
Iain Buclaw
December 08, 2021
https://issues.dlang.org/show_bug.cgi?id=12808

Stanislav Blinov <stanislav.blinov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.blinov@gmail.com

--- Comment #1 from Stanislav Blinov <stanislav.blinov@gmail.com> ---
Rewritten relevant parts into contemprary D. With dmd 2.098:

void program2() @nogc {
    foreach (x; [1, 2]) {}
}

import std.array : staticArray;

void program3() @nogc {
    import std.algorithm: filter;
    foreach (x; [1, 2].filter!(x => true)) {} // fails to infer @nogc
    // workaround:
    foreach (x; [1, 2].staticArray[].filter!(x => true)) {}
}

int[] program5() @nogc {
    return [1, 2].staticArray; // detects the escape correctly
}
void main() {}

So I guess the only outstanding enhancement here is to make this infer @nogc:

foreach (x; [1, 2].filter!(x => true)) {}

...if at all possible. If not, I guess this could be closed?

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=12808

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=12808

--- Comment #2 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18832

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--