inout/const issue: assignments to field not allowed if field initializer present

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Mar 10 17:46:14 PST 2012


It took me a while to narrow this down:

struct Foo
{
    int val = int.init;
    this(inout(int) nval) inout {
        this.val = nval;
    }
}

test.d(18): Error: cannot modify const/immutable/inout expression this.val

Is there any special reason why this should be disallowed? I mean the
same thing happens if you do a void initialization: int val = void;

A bug?


More information about the Digitalmars-d-learn mailing list