Comment #0 by dlang-bugzilla — 2015-11-07T01:07:30Z
///////////////////////// 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.
Comment #1 by dlang-bot — 2021-08-23T14:39:10Z
@ibuclaw created dlang/dmd pull request #13006 "fix Issue 15298 - Can't call nested template function unless it's anonymous" fixing this issue:
- fix Issue 15298 - Can't call nested template function unless it's anonymous
https://github.com/dlang/dmd/pull/13006
Comment #2 by robert.schadek — 2024-12-13T18:45:41Z