this idiom for creating static array used to work, but they are failing now.
What changed and whats the alternative?

(from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits)


T[n] s(T, size_t n)(auto ref T[n] array) pure nothrow @nogc @safe
{
    return array;
}

void main() @nogc
{
int[] myDynamicArray = [1, 2, 3].s; // Slice that static array which is on stack
}

//output:
Deprecation: slice of static array temporary returned by s([1, 2, 3]) assigned to longer lived variable myDynamicArray

Reply via email to