mixin template silently `override` without even a warning message!
mw
mingwu at gmail.com
Sun Oct 9 07:16:07 UTC 2022
Even more fun when we have attribute of the same name:
```
import std;
template Foo() {
int a;
void foo() {writeln(a);}
void bar() {foo();}
}
class A {
mixin Foo;
int a;
void foo() {writeln(a);}
}
void main() {
A a = new A();
a.a = 911;
a.bar(); // print 0
a.foo(); // print 911
}
```
So `class A` has another hidden `Foo.a` attribute, but cannot
read / write it's value outside of Foo?
More information about the Digitalmars-d
mailing list