Related to issue 14656 (printing bad "auto") and issue 9204 (can't alias auto ref function). This errors out: ---- void unaryFun()(auto ref int a) pure nothrow @safe @nogc {} void main() { alias u = unaryFun!(); } ---- test.d(1): Error: auto can only be used for template function parameters test.d(4): Error: template instance test.unaryFun!() error instantiating But these compile and print different types: ---- void unaryFun()(auto ref int a) pure nothrow @safe @nogc {} void main() { unaryFun!()(41); alias u = unaryFun!(); pragma(msg, typeof(u)); /* ...(auto int a) */ } ---- ---- void unaryFun()(auto ref int a) pure nothrow @safe @nogc {} void main() { int x; unaryFun!()(x); alias u = unaryFun!(); pragma(msg, typeof(u)); /* ...(auto ref int a) */ } ---- I think they should either all error or all print "auto ref int".
IMHO this should not work: alias u = unaryFun!(); it does not make sense. In curent dmd it alias to first template instantiation. So even this does not work: void unaryFun()(auto ref int a) pure nothrow @safe @nogc {} void main() { int x; unaryFun!()(x); unaryFun!()(41); alias u = unaryFun!(); u(41); } m.d(8): Error: function m.unaryFun!().unaryFun (auto ref int a) is not callable using argument types (int) So I would say alias u = unaryFun!(); should be forbidden and some better error message can be print. Something like this: Error: alias u = unaryFun!() cannot be use do you mean alias u = unaryFun?
Ok maybe I am wrong: template unaryFun() { void unaryFun(ref int a) pure nothrow @safe @nogc {} void unaryFun(int a) pure nothrow @safe @nogc {} } void unaryFun2()(auto ref int a) pure nothrow @safe @nogc {} void main() { int x; alias unaryFun!() u; alias unaryFun2!() u2; u(41); u2(41); } this works ok for u, but not for u2.
*** This issue has been marked as a duplicate of issue 9204 ***