[Issue 14657] New: can alias auto ref function but only after it's been called before
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jun 5 13:03:27 PDT 2015
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 at puremagic.com
Reporter: ag0aep6g at 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".
--
More information about the Digitalmars-d-bugs
mailing list