This example from basic.lox
fun returnSum(a: number, b: number): number {
return a + b;
}
// Closures
fun identity(a: (number, number) => number): (number, number) => number {
return a;
}
print identity(returnSum)(1, 2); // prints "3";
currently results in an error Cannot call a non-function
(Actually, the comment 'Closures' is in my view a misnomer, it is 'just' passing a function reference (or value or pointer (?) ) as an argument. The feature of closures is not used here, that the current scope of variables is preserved for the later execution of the function.)
Expected behaviour would be that function identity is called with reference to function as argument, which is returned,
and then apply (1, 2) on that function returnSum and execute it.