john-liu / jaql

Automatically exported from code.google.com/p/jaql
0 stars 0 forks source link

reverse() is broken #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
the reverse function fails with the following exception:

reverse([1,2,3]);

java.lang.NullPointerException: undefined variable: $
java.lang.NullPointerException: undefined variable: $
        at com.ibm.jaql.lang.core.Var.getValue(Var.java:208)
        at com.ibm.jaql.lang.expr.core.VarExpr.eval(VarExpr.java:102)
        at com.ibm.jaql.lang.expr.core.IndexExpr.eval(IndexExpr.java:142)
        at com.ibm.jaql.lang.expr.core.CmpSpec.eval(CmpSpec.java:104)
        at com.ibm.jaql.lang.expr.core.CmpSingle.eval(CmpSingle.java:67)
        at com.ibm.jaql.lang.expr.core.SortExpr.iter(SortExpr.java:113)
        at com.ibm.jaql.lang.expr.core.BindingExpr.iter(BindingExpr.java:213)
        at
com.ibm.jaql.lang.expr.core.TransformExpr.iter(TransformExpr.java:148)
        at com.ibm.jaql.lang.Jaql.run(Jaql.java:405)
        at com.ibm.jaql.lang.Jaql.run(Jaql.java:67)
        at
com.ibm.jaql.util.shell.AbstractJaqlShell.runInteractively(AbstractJaqlShell.jav
a:48)
        at
com.ibm.jaql.util.shell.AbstractJaqlShell.main(AbstractJaqlShell.java:84)
        at JaqlShell.main(JaqlShell.java:272)

The explain output is the following:
explain reverse([1,2,3]);
Invalid query... Undefined variables:
$
$ = ( [1, 2, 3]
-> enumerate() )
  -> sort using ((index($, 0)) desc)
-> transform each $ (index($, 1))

The working solution should look like this:
( [1, 2, 3]-> enumerate() )
-> sort using (fn($) cmp [(index($, 0)) desc])
-> transform each $ (index($, 1));

Original issue reported on code.google.com by jasper.o...@de.ibm.com on 8 Sep 2009 at 6:50

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r306.

Original comment by jasper.o...@de.ibm.com on 9 Sep 2009 at 12:10