//====
pure unittest
{
}
//====
OK!
//====
unittest pure
{
}
//====
Error: statement expected to be { }, not pure
This is inconsistent with how functions can be qualified. I, and others have been hit by this, and is quite a pain.
ANother argument for allowing it is that the word "unittest" remainsthe first word of the line, making it easier to detect *as* a unittest when scanning through a document, rather than some function.
Comment #1 by sfrijters — 2015-03-22T11:00:40Z
I have also run into this issue today and would rather like to see it fixed / allowed, for the same reasons given by monarchdodra.
Comment #2 by k.hara.pg — 2015-03-22T11:29:20Z
Historically invariant block needed parenthesis until 2.065.
class C {
invariant {} // Error until 2.065, allowed from 2.066
}
And "postfix attributes" is valid only for functions.
class C {
void fun() pure { ... } // OK
int function() fptr pure; // NG
}
If we allow postfix attributes on unittest and invariant blocks, I'd like to force the empty parameter list `()` to make the syntax similar to functions.
class C {
unittest() pure { ... } // proposal
invariant() pure nothrow { ... }
}