I think this code should be allowed, but it isn't:
struct Functor (T)
{
T a;
auto ref fmap (alias f)()
{
return Functor (f(a));
}
}
auto ref identity (T)(auto ref T a)
{
return a;
}
void main()
{
Functor!int a;
static auto id (T)(T x)
{return x;}
a.fmap!identity; // ok
a.fmap!id; // ok
a.fmap!((int x) => x); // ok
a.fmap!(x => x); // Error: template instance fmap!((x) => x)
cannot use local '__lambda1' as parameter to non-global template
fmap(alias f)()
}
This seems like one of those things that doesn't work because of
some compiler implementation detail rather than a consequence of
the language rules but I'm not sure. Opinion?