auto myfun(int foo)
{
auto b = foo;
}
pure @safe nothrow unittest
{
myfun(2);
}
However once the return type is void - the compiler tells me that I have an impure system function!
Is this by design or a bug?
void myfunv()
{
int b = 2;
}
pure @safe nothrow unittest
{
myfunv();
}
(removing/adding the parameter doesn't make a difference)
Comment #1 by mathias.lang — 2016-04-12T18:15:39Z
It is by design.
The compiler will perform attribute inference on `auto` returning functions and templates, but not on function where the full prototype is provided.
Attribute inference for regular function would make it impossible to provide the prototype of a function in a sane way (as you can provide `.di` files which are D equivalent of headers).
Closing as invalid, feel free to head to the 'learn' forum if you have any more question.