Lambda cannot access frame of function

kerdemdemir kerdemdemir at gmail.com
Sat Nov 18 14:22:19 UTC 2017


//DMD64 D Compiler 2.072.2
import std.stdio;

bool foo(  bool function( double ) controlFoo )
{
     return controlFoo(5.0);
}

void foo2( double val )
{
     writeln  ( foo( a => a > val ) );
}

void main()
{
     foo2(20);
     writeln("Hello, World!");
}

Does not compile and gives this errors:
source_file.d(12): Error: function source.foo2.__lambda2 cannot 
access frame of function source.foo2
source_file.d(12): Error: function source.foo (bool 
function(double) controlFoo) is not callable using argument types 
(void)

Live example:
http://rextester.com/WRKCWR55408

Is there any workaround for that?

Regards
Erdem



More information about the Digitalmars-d-learn mailing list