static if(true)
version = Foo;
version(Foo) {}
test.d(2): Error: version Foo defined after use
The compiler's evaluation seems to occur in the wrong order ("versions before static ifs" instead of "top to bottom"), because this works:
static if(true)
version = Foo;
static if(true)
version(Foo) {}