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

--- Comment #15 from [email protected] ---
Another common case where I'd like the compiler to avoid GC-allocations:

void main() @nogc {
    immutable int[4] a1 = [1, 2, 4, 5];
    size_t i = 2;
    immutable int[5] a2 = a1[0 .. i] ~ 3 ~ a1[i .. $];
}


Currently you have to write this more bug-prone code and the 'a2' variable
can't be immutable:

void main() @nogc {
    immutable int[4] a1 = [1, 2, 4, 5];
    size_t i = 2;
    int[5] a2 = void;
    a2[0 .. i] = a1[0 .. i];
    a2[2] = 3;
    a2[i + 1 .. $] = a1[i .. $];
}

--

Reply via email to