More on immutable

bearophile bearophileHUGS at
Mon Mar 8 06:08:26 PST 2010

I am trying to learn more about the usage of immutable. This is a little D2 program:

immutable class S {
    static int x;
    static this() {
        S.x = 10;
void main() {}

The compiler outputs:
test.d(3): Error: function test2.S._staticCtor1 without 'this' cannot be const/immutable

Can you tell me what's wrong or how I can fix it?

Bye and thank you,

More information about the Digitalmars-d-learn mailing list