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); }
Added to DStress as http://dstress.kuehne.cn/nocompile/t/tupelof_01_A.d http://dstress.kuehne.cn/nocompile/t/tupelof_01_B.d
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.
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9024f3680dc69edc20268cbcd7277016d165641d Fix issue 1099 weird tupleof behavior in mixins Fixed some time ago, this is just the test case https://github.com/D-Programming-Language/dmd/commit/85c54827db14f5a547015ab4a19fdd677f5449aa Merge pull request #949 from donc/bug1099testcaseonly Fix issue 1099 weird tupleof behavior in mixins