I'm trying to assign (or simply bit-copy) over 'this' inside a constructor. There's an error when compile-time constructing the object. Is this a bug in DMD (2.062) ?

module main;

struct Test
{
    enum Test t = Test(1);
    int v;

    this(int)
    {
        v = 123;
    }

    this(int, int)
    {
        this = t;
    }
}

void main()
{
    Test t1 = Test(11, 22);
    writeln(t1.v); // Prints: 123

    enum t2 = Test(11, 22); // Error:
// CTFE internal error: unsupported assignment this = Test(123)
}

Reply via email to