www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D2: immutable/const and delegates

reply klickverbot <see klickverbot.at> writes:
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?
Sep 08 2010
parent klickverbot <see klickverbot.at> writes:
On 9/8/10 11:46 AM, klickverbot wrote:
 Am I severely misunderstanding something here, or is this a rather big
 hole in the type system?
Ah, never mind, there is even a (more than two years old!) bug report about it: http://d.puremagic.com/issues/show_bug.cgi?id=1983
Sep 08 2010