I opened the following bug before reading reduce's documentation carefully:

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

import std.stdio;
import std.algorithm;

void main()
{
    int[] arr = [ 0 ];

    int[1] seed;
    int[] result = reduce!((sum, _) => sum[])(seed, arr);

    writefln("%s", result);
}

The output is garbage like [373728176].

Note that the original seed is a value type, which is later sliced by the lambda.

Now I think that it can be considered a user error. Do you agree whit that? If so, this is something else we should be careful about similar to the internal buffer of byLine.

Ali

Reply via email to