June 07, 2022
https://issues.dlang.org/show_bug.cgi?id=23170

          Issue ID: 23170
           Summary: Array literal passed to map in lambda, then returned
                    from nested function, is memory corrupted
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: default_357-line@yahoo.de

Consider this code:

import std.algorithm;
import std.conv;
import std.range;

void main()
{
    auto result = ({ return [1, 2, 3].badMap; })().array;

    assert(result == [1, 2, 3], result.to!string);
}

alias badMap = range => range.map!(a => a);

Expected: No output.

Actual output: core.exception.AssertError@foo.d(9): [1, 2, 623040144]

(Numbers vary semi-randomly.)

Works on DMD 2.091.1.
Crashes on 2.092.0, 2.097, 2.099 and 2.100. (Thanks ndf!)

--