mixin module template -> undefined identifier
Robert Schadek
realburner at gmx.de
Thu Oct 3 10:51:44 PDT 2013
I have some found some irregular behavior when using mixins with
template and modules. If a aggregation is defined in the same module it
is found. If the aggregation is defined in another module it fails. And
I wonder if this is be design. For comparison see the code below.
// file: moduleA.d
module A;
public int func(T)() {
return mixin(T.stringof ~ ".fun()");
}
struct Bar {
static int fun() {
return 2;
}
}
unittest {
static assert(func!Bar() == 2);
}
// file: moduleB.d
import A;
struct Foo {
static int fun() {
return 1;
}
}
void main() {
assert(func!Foo() == 1);
}
dmd moduleA.d moduleB.d -ofmix -unittest
moduleA.d(4): Error: undefined identifier Foo
moduleB.d(10): Error: template instance A.func!(Foo) error instantiating
More information about the Digitalmars-d
mailing list