Compiler bug? Mixin behavior order dependent
Norbert Nemec
Norbert at Nemec-online.de
Sun Oct 16 09:24:30 PDT 2011
Hi there,
can anyone give an explanation for the following or is it simply a
compiler bug?
The code below does not compile. I don't see why the enum cannot be
forward referenced across mixin boundaries while the other two forward
references are no problem. (Ordering the mixing statement below the enum
definition also solves the problem)
=====================
mixin template verifyArray() {
static assert(is(type)); // no problem
static assert(rank >= 0); // Error: forward reference
}
struct MyArray(T,int R) {
mixin verifyArray;
static assert(rank >= 0); // no problem
alias T type;
enum rank = R;
}
unittest {
MyArray!(int,4) x;
}
=====================
./bug_mixin_order.d(5): Error: forward reference of variable rank
./bug_mixin_order.d(9): Error: mixin
MyArray(int,4).MyArray.verifyArray!() error instantiating
./bug_mixin_order.d(16): Error: template instance MyArray!(int,4) error
instantiating
=====================
Any ideas?
Greetings,
Norbert
More information about the Digitalmars-d
mailing list