On Wed, Dec 10, 2008 at 5:31 PM, Weed <[EMAIL PROTECTED]> wrote: > code: > > import std.stdio; > > class MyClass > { > invariant uint a = 0; > } > > void main() > { > static MyClass c = new MyClass; > writeln( c.a ); > }
It's not the class member that wants static initialization, it's your variable declaration. static MyClass c = new MyClass; This is illegal because static variables must be initialized with compile-time constants. The simple way around this is: static MyClass c; // defaults to null c = new MyClass; Which separates the declaration from initialization.