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...


Reply via email to