Idan Arye:

today I've seen a question in Stack Exchange's Programmers board that raises a point I don't recall being discussed here:

This program:

class A {
    immutable int x;
    this() {
        foo();
        x = 1;
        x = 2;
    }
    void foo() {
        auto y = x;
    }
}
void main() {}


Gives:

temp.d(6,9): Error: immutable field 'x' initialized multiple times

So D can tell x is initialized more than 1 time, but it can't tell x is initialized 0 times inside foo().

Bye,
bearophile

Reply via email to