[Bug?] Attributes for invariant()

Volodymyr via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 2 05:52:02 PST 2015


class A
{
	private bool isA() const pure @safe // OK
	{
		return true;
	}
	
	invariant() @safe pure const // Error, statement block expected
         // @safe pure const invariant() // OK
	{
		assert(isA);
	}
}

Does sufix-attribute style prohibited for invariant? Does it have
any sence to mark it with this attributes? As for me invariant
have to be const and pure by definition.

Also:
class A
{
	
	invariant // Error: use 'immutable' instead of 'invariant'
	{
		assert(true);
	}
}

http://dlang.org/contracts.html#Invariants

[compiled with http://dlang.org/]


More information about the Digitalmars-d mailing list