ceylon/ceylon-spec — Issue #220: function references are broken
Author: chochos
Created: 2012-03-07 07:13:43+00:00
State: open

I know this is still a work in progress, but anyway... I have this code:

````
void run() {
class Caca() {
shared String upper(Integer x) {
return "INT " x "";
}
}
void higher(String f(Integer i)) {
print(f(100));
}
value x = Caca();
function y(Integer i)=x.upper;
higher(y);
}
````

ceylonc throws NPE on the line `function y(Integer i)=x.upper;`:
````
java.lang.NullPointerException
at com.redhat.ceylon.compiler.java.codegen.CeylonVisitor.visit(CeylonVisitor.java:166)
````

And then complains about symbol not found on the next line (doesn't know `y`).

ceylonjs compiles all the code but nothing is generated for that same line. I even implemented `visitAny(Node)` and never got a Node located on line 13, so obviously the code doesn't run because `y` is undefined.

I'm guessing the problem is that the function reference does not generate a Node yet, so Visitors never get it and so never generate anything for it.