Wrong const attribute?

Paolo Invernizzi arathorn at fastwebnet.it
Thu Sep 22 04:12:49 PDT 2011


Hi all, 

I've found nothing on bugzilla for that, what I'm missing? Or it's a bug? (DMD 2.055)

struct Bar {
    immutable int i;
    this(int j){ i = j; }
}

struct Foo {
    Bar bar;
}

void main(){
    
    auto b = Bar(1);
    
    auto f = Foo();
    f.bar = Bar(2); // Error: can only initialize const member bar inside constructor
    
}

Cheers, 
Paolo Invernizzi


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110922/517c5401/attachment.html>


More information about the Digitalmars-d-learn mailing list