fontoxpath
fontoxpath copied to clipboard
"Cannot read property 'next' of undefined" error when calling an updating function in array:for-each
Can be reproduced with:
<p>This is a paragraph <b>for</b> testing <b>and</b> such.</p>
declare %private %updating function Q{x}nuke-it($x) {
delete node $x
};
let $bolds := //b, $arr := array {$bolds[1], $bolds[2]} return
array:for-each($arr, Q{x}nuke-it#1)
This now results in the error "Cannot read property 'next' of undefined".
The same works fine with a non-updating function e.g. trace#1
Funnily enough, the spec does not say anything about this. I think in this case we are not able to statically determine whether the array function will 'turn' updating depending on its arguments. I think we should disallow this. @JosVerburg , what do you think?
Would it not allow updating expressions to be inserted in it like here https://github.com/LeoWoerteler/XQUTS/blob/master/Queries/XQuery/FunctionCall/id-function-call-01.xq
that is an updating function argument. the bug we have now is an updating function that is executed as a hicher order function, without the invoke updating function stuff you'd normally use
Still present: https://xpath.playground.fontoxml.com/?state=H4sIACeKPGIAA01P24qDQAz9lTDrQgt2pX10Xf%2BhsG9rH6KT1mFtHOJMsYj%2F3mgpFAI5ObmdM5lrb8nkh9TcUBzWHQ0mN9NsUjNeO4WFL39bN4AGgkfBi6BvoajLcy9FVpcQaAiOLwuFbFdqiE37VWS%2BrHg5dIwkd71lqelQCD69uBsGBdFbXJfPkZvgeobjNM4c%2F2nnwiYZtzBVDGCpIx1n1QrJWPH8XbEykNR9ZwfIfyDL6hQSFFkKTXiH6dn925%2B084SH0wxCIQpXvA7lamJH2LSbZTd9%2F%2F6x36r2pudAY3g5MPMDZTNhfTIBAAA%3D