Insering dynamic variables into custom volt function doesn't work

Hello. I have a problem with accessing variables in my custom function.

So for example my code is:

{{ myFunction(variableFromController) }}

And PHP:


    $arg = $compiler->expression($exprArgs[0]['expr']);
    $lang = $di->get('lang');
    echo $lang->translate($arg);     


So problem is that compiler will return variable as string "$variableFromController", where i'm doing it wrong ?

edited Aug '14

Closures/Anonymous functions are not supposed to implement the functional code 'myFunction' must perform. Closures/Anonymous functions are supposed to return a string that is inserted into the PHP code generated by Volt:

$compiler->addFunction('myFunction',function($resolvedArgs, $exprArgs) use($compiler) {
    $arg = $compiler->expression($exprArgs[0]['expr']);
    return "\$this->lang->translate('" . $arg . "')";    

Could you tell me your dev envirounment params? which OS and hardware? Cause I have problems with using custom functions at all.