Position of unittest attributes

Stefan Frijters via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 22 02:29:37 PDT 2015


So I was trying to add some attributes to unittests in my code, 
but apparently they are only allowed *before* the unittest 
keyword, which I think makes it much harder to quickly see the 
unittests when scrolling through the code:

void foo() @safe pure nothrow @nogc { } // Ok - I normally use 
this style, and Phobos does too, I think?
@safe pure nothrow @nogc void bar() { } // Ok

@safe pure nothrow @nogc unittest { foo(); } // Ok
unittest @safe pure nothrow @nogc { bar(); } // Nope

I looked through the D grammar and it does seem to disallow this, 
so it's not a bug as such, but is there a particular reason to 
not allow it?


More information about the Digitalmars-d-learn mailing list