On 10/26/10 11:35 CDT, osa wrote:
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...

In this particular case the decision goes both ways, and both have something going for them. You may want to submit a bug report at least to prompt us to change the documentation to clarify the behavior.

A workaround is to define opAssign(Bar).


Andrei

Reply via email to