BaseXdb/basex — Issue #382: NPE parsing function item literals of user-defined functions
Author: LeoWoerteler
Created: 2012-02-16 14:09:36+00:00
State: open
Labels: bug, XQuery

The lookup of function items unconditionally tries to compile the function, which leads to errors if it isn't declared yet.

Example:
-------------
```xquery
declare function local:a() { local:b() };
declare function local:b() { 42 };
local:a#0()
```

throws:

```
Exception in thread "main" java.lang.NullPointerException
at org.basex.query.func.UserFuncCall.comp(UserFuncCall.java:105)
at org.basex.query.func.UserFunc.comp(UserFunc.java:105)
at org.basex.query.func.UserFunc.comp(UserFunc.java:86)
at org.basex.query.func.UserFuncs.get(UserFuncs.java:149)
at org.basex.query.QueryParser.functionItem(QueryParser.java:2114)
at org.basex.query.QueryParser.primary(QueryParser.java:2038)
...
```