Hi,
Within my environment, I am experiencing some frustrating behavior of the
Xquery Basex engine. I've done my best to single out the problem in the
following XQUERY code :
declare function local:wtf($x as item() ) {function() { $x}};
declare function local:dummy($f,$x) {
if(fn:empty($f())) then local:wtf($x) else local:wtf(())};
declare variable $insert := local:dummy(function(){ () }, function() { (),
()} );
fn:count($insert())
The issues are :
1) executing this code yields an "Improper use? Potential bug?" exception
(see details further on).
2) If I change the execution query to be
fn:count(local:dummy(function(){ () }, function() { (), ()} )()) ( I just
copy and pasted the value of $insert into the fn:count(..) ) then the query
is executed normally, returning "1".
3) If I change the function declaration local:wtf as follow
declare function local:wtf($x) {function() { $x}}; (I just removed "as
item()"), then the query is executed normally, returning "1".
Can you reproduce it with another environment ?
Cheers,
Jean-Marc
Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk(a)mailman.uni-konstanz.de
Version: BaseX 7.8 beta 6aeaebf
Java: Oracle Corporation, 1.7.0_05
OS: Windows 7, amd64
Stack Trace:
java.lang.NullPointerException
at org.basex.query.value.item.FuncItem.inlineExpr(FuncItem.java:308)
at org.basex.query.func.DynFuncCall.optimize(DynFuncCall.java:58)
at org.basex.query.func.DynFuncCall.compile(DynFuncCall.java:39)
at org.basex.query.expr.Arr.compile(Arr.java:40)
at org.basex.query.func.StandardFunc.compile(StandardFunc.java:60)
at org.basex.query.MainModule.compile(MainModule.java:63)
at org.basex.query.QueryCompiler.compile(QueryCompiler.java:70)
at org.basex.query.QueryCompiler.compile(QueryCompiler.java:61)
at org.basex.query.QueryContext.analyze(QueryContext.java:270)
at org.basex.query.QueryContext.compile(QueryContext.java:253)
at org.basex.query.QueryProcessor.compile(QueryProcessor.java:71)
at org.basex.core.cmd.AQuery.query(AQuery.java:81)
at org.basex.core.cmd.XQuery.run(XQuery.java:22)
at org.basex.core.Command.run(Command.java:323)
at org.basex.core.Command.execute(Command.java:92)
at org.basex.server.LocalSession.execute(LocalSession.java:121)
at org.basex.server.Session.execute(Session.java:37)
at org.basex.core.Main.execute(Main.java:146)
at org.basex.BaseX.<init>(BaseX.java:119)
at org.basex.BaseX.main(BaseX.java:38)