On Friday, 13 November 2015 at 04:03:23 UTC, Walter Bright wrote:
On 11/12/2015 5:14 PM, deadalnix wrote:
module a;
struct S(E) {
import std.bitfield;
mixin(bitfield!(
bool, "flag", 1,
T, "myT", SizeOf!T,
uint, "", 32 - SizeOf!T - 1,
));
}
module b;
enum MyEnum { Val1, Val2, Val3 }
import a;
alias UsefulStruct = S!MyEnum; // Boom, MyEnum is undefined
Now you end up having to tie stupid node into your code, like
adding all user of
library X as import in library X. Which sucks, but is forced
by the language
design.
The trouble there is that E is turned into MyEnum in the mixin
string, and MyEnum would be unknown to module a.
You can file an enhancement request on this in bugzilla if you
like.
I know what the problem is. Hence you need to import a in b and b
in a. There is not really anyway around this because this is
intrinsically how mixin works.