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

Simen Kjaeraas <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #7 from Simen Kjaeraas <[email protected]> ---
The problem is reducible to this:

unittest {
    import std.stdio, std.typetuple;
    const fun1 = () => 0;
    const fun2 = () => 1;
    foreach (i, f; AliasSeq!(fun1, fun2)) {
        alias f2 = Alias!f;
        assert(i == f(), "foreach alias works great");
        assert(i == f2(), "template is incorrectly cached");
    }
}

As we can see, the issue occurs when f is passed to a template. It seems DMD
caches the template instantiation and doesn't update it for each iteration.

--

Reply via email to