Fighting with alias this: bugs or features?

osa osa at aso.osa
Tue Oct 26 09:35:21 PDT 2010


Every time I'm trying to use alias this (which looks like a nice 
feature, on paper), I end up with problems. This is the most recent one 
(dmd v2.049):
------
struct Foo {}
class Bar {
     Foo foo_;
     alias foo_ this;
}

void main() {
     auto a = new Bar;
     auto b = a;
     a = null; // fails -- Error: cannot implicitly convert expression 
(null) of type void* to Foo
}
------
There are plenty of 'alias this' issues in Bugzilla, but I cannot find 
this particular problem there. So is this a bug or feature? The language 
spec does not help do decide...




More information about the Digitalmars-d mailing list