I always thought I had understood the new const/immutable system of D2. But now this:

---
import std.stdio;

class A {
   void setI( int newI ) {
      i = newI;
   }
   int i;
}

void main() {
   immutable a = new immutable(A);

   writefln( "Before: %s", a.i );
   ( &a.setI )( 42 );
   writefln( "After: %s", a.i );
}
---

I would expect this not to compile, but for some reason it does (and the assignment works, a.i is 42 after the call to setI).

Am I severely misunderstanding something here, or is this a rather big hole in the type system?

Reply via email to