"Every unittest should be annotated (e.g. pure nothrow @nogc @safe unittest { ... }) to ensure the existence of attributes on the templated function."
But, templated functions should not be annotated. So, do you mean "... on a non-templated function"? Or maybe "... on the tested function"?
Comment #1 by b2.temp — 2017-10-07T11:47:38Z
attributes of the unittest blocks are tried on the free functions that are used inside. Actually you can see a unittest{} as a function itself. (the getunittests traits returns some void function()).
Comment #2 by b2.temp — 2017-10-07T11:58:02Z
to be perfectly clear about the invalidity, see:
https://dlang.org/spec/function.html#function-attribute-inference
void call1 () @safe{} // non templatized so no attrib inference
void call2 ()(){} // attrib infered by the caller
@safe unittest
{
// everything inside **must** be safe or trused.
call1();
call2();
}
//is like
void test() @safe
{
call1();
call2(); // @safe is infered on call2, so that if not supported compil stops.
}
Comment #3 by kroeplin.d — 2017-10-07T12:24:47Z
(In reply to b2.temp from comment #2)
The issue is just the wording of the guideline:
"to ensure the existence of attributes on the templated function":
which "templated function"?
Comment #4 by b2.temp — 2017-10-07T12:43:49Z
(In reply to Mario Kroeplin from comment #3)
> (In reply to b2.temp from comment #2)
>
> The issue is just the wording of the guideline:
> "to ensure the existence of attributes on the templated function":
> which "templated function"?
in the example it's "call2". Maybe if you're not comfy enough with D try
https://forum.dlang.org/group/learn
before opening an issue.