[Issue 15298] New: Can't call nested template function unless it's anonymous
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Nov 6 17:07:30 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15298
Issue ID: 15298
Summary: Can't call nested template function unless it's
anonymous
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: dmd
Assignee: nobody at puremagic.com
Reporter: thecybershadow at gmail.com
///////////////////////// test.d /////////////////////////
// Call alias with a parameter.
void callAlias(alias f)()
{
f(42);
}
alias Identity(alias X) = X;
void main()
{
int local;
// Declare an anonymous function template
// which writes to a local.
alias a = Identity!((i) { local = i; });
// Declare a function template which does
// the same thing.
void b(T)(T i) { local = i; }
callAlias!a; // Works
callAlias!b; // Error: function test.main.b!int.b is a
// nested function and cannot be accessed
// from test.callAlias!(b).callAlias
}
//////////////////////////////////////////////////////////
As far as I can tell, a and b are essentially the same, except one is
anonymous.
--
More information about the Digitalmars-d-bugs
mailing list