November 05, 2021

Hi,

This week I hit another dead end with regards to changing _d_arrayctor's signature. More specifically, a signature that should pass all tests as well as make use of NRVO is this one:

Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @trusted
{
    // ...
    Tarr1 to;
    // ...
    return to;
}

However, there seems to be an bug old bug concerning nested structs whereby the compiler doesn't allow me to create to when T1 is a nested struct, as in the example below, taken from this unittest:

@safe unittest
{
    int counter;
    struct S
    {
        int val;
        this(this) { counter++; }
    }

    S[4] arr1;
    S[4] arr2 = [S(0), S(1), S(2), S(3)];
    arr1 = _d_arrayctor!(typeof(arr1), typeof(arr2), S, S)(arr2[]);
}

I wrote this forum post to ask tho community what to do about this bug. I tried to give as detailed of an account of the situation as I could. The bug is has been previously reported here, but it seems it's still active:

As a result, I've switched over to the _d_arrayappend hooks once more and am looking forward to progress with those in the near future.

Thanks,
Teodor