www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Weird "nested function cannot be accessed" error

This code fails to compile:

void bar(alias f)() {
     f();
}

void foo(alias f)() {
     bar!f();
}

void main() {
     void f()() {
     }
     foo!f();
}

Error: function test.main.f!().f is a nested function and cannot 
be accessed from test.bar!(f).bar


But non-template nested functions are accepted:

void main() {
     void f() {
     }
     foo!f(); // ok
}


What's going on here?
May 29 2016