April 03, 2008
I can't figure out how to instantiate a class as invariant.  The following code issues this error:  cannot implicitly convert expression (new A) of type hello.A to invariant(A)

class A {}

int main(char[][] args)
{
 invariant A a = new A;
 return 0;
}

-Craig 

April 03, 2008
Craig Black wrote:
> I can't figure out how to instantiate a class as invariant.  The following code issues this error:  cannot implicitly convert expression (new A) of type hello.A to invariant(A)

You'll have to do a cast at some point. This isn't the most robust way as the compiler won't be able to check if it really is invariant, and we are working on some ideas to improve it, but that's the way it is at the moment.