28msec / zorba

JSONiq & XQuery Query Processor
http://zorba.28.io/
Apache License 2.0
114 stars 22 forks source link

Partial Apply Issue: error [zerr:ZXQP0002]: "false": assertion failed #219

Open dknochen opened 8 years ago

dknochen commented 8 years ago

This simple main query hits the assertion zerr:ZXQP0002:

jsoniq version "1.0";

declare function local:test($res as object*, $token as string) as item
{
  <test>{ $token }</test>
};

declare function local:get($token as string) as object
{
    {
        test: local:test(?, $token)
    }
};

let $test := local:get("test")
return $test.test(())

The key is that the local:test(...) function return an xml node. The reason is probably this assertion: https://github.com/28msec/zorba/blob/36ea8f6c5a55f7f856975d6af9b7f5beabfb209f/src/runtime/hof/dynamic_fncall_iterator.cpp#L315

dknochen commented 8 years ago

A workaround is to rewrite the partial apply into a function item wrapper:

jsoniq version "1.0";

declare function local:test($res as object*, $token as string) as item
{
  <test>{ $token }</test>
};

declare function local:get($token as string) as object
{
    {
        test: function($res as object*){ 
                    local:test($res, $token) 
                }
    }
};

let $test := local:get("test")
return $test.test(())