digitalmars.D.bugs - [Issue 14657] New: can alias auto ref function but only after it's
- via Digitalmars-d-bugs (48/48) Jun 05 2015 https://issues.dlang.org/show_bug.cgi?id=14657
https://issues.dlang.org/show_bug.cgi?id=14657 Issue ID: 14657 Summary: can alias auto ref function but only after it's been called before Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: minor Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com 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". --
Jun 05 2015