template mixin bug?
Simen Haugen
simen at norstat.no
Tue Nov 13 07:38:58 PST 2007
I have a mixin like this:
template M() {
int i() {
return _i;
}
private:
int _i;
}
But if I try to add a setter function to my class that uses the mixin, the
compiler gets confused (seems like its hiding the mixed in function):
class C {
mixin Mixin;
void i(int a) {
_i = a;
}
}
void main() {
C c = new C;
c.i = 12;
assert(c.i == 12);
}
Now it fails to compile if I try to use the get method from the mixin. If I
don't use the method, it compiles.
t.d(29): function test.C.i (int) does not match parameter types ()
t.d(29): Error: expected 1 arguments, not 0
t.d(29): Error: void has no value
t.d(29): Error: incompatible types for (((c.i)()) == (12)): 'void' and 'int'
Is there a reason I cannot do this, or is it a compiler bug? I'm using dmd
1.023.
More information about the Digitalmars-d
mailing list