Weird "nested function cannot be accessed" error

Max Samukha via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 29 00:50:53 PDT 2016


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?


More information about the Digitalmars-d-learn mailing list