the following module should not compile, but it does. Tested with dmd 0.175, 1.010 and 1.010b.
template Mix(int a) {
alias typeof(*this) ThisType;
static assert (ThisType.init.tupleof.length == a);
}
struct Foo {
mixin Mix!(0);
int foo;
mixin Mix!(1);
int bar;
mixin Mix!(2);
}
Perhaps D is designed to work this way? Mixin template instances also don't see fields declared after their mixing-in point, so it's kind of consistent... But pretty weird/confusing anyway.
Comment #3 by github-bugzilla — 2012-05-14T16:20:14Z