The following code fails: template Foo() { mixin("alias char[] TheType;"); static if (is(TheType : char[])) static assert(true); else static assert(false); } alias Foo!() instance1; mixins1.d(7): static assert is false The following similar programs all compile: // 1. Replace the mixin with the statement itself template Foo() { alias char[] TheType; static if (is(TheType : char[])) static assert(true); else static assert(false); } alias Foo!() instance1; // 2. Add a dummy declaration at the beginning of the template template Foo() { char[] dummy; mixin("alias char[] TheType;"); static if (is(TheType : char[])) static assert(true); else static assert(false); } alias Foo!() instance1; // 3. Replace static if with static assert template Foo() { mixin("alias char[] TheType;"); static assert(is(TheType : char[])); } alias Foo!() instance1;
Adde to DStress as http://dstress.kuehne.cn/compile/m/mixin_35_A.d http://dstress.kuehne.cn/compile/m/mixin_35_B.d http://dstress.kuehne.cn/compile/m/mixin_35_C.d http://dstress.kuehne.cn/compile/m/mixin_35_D.d
This was fixed in DMD1.020 or earlier.