unexpected results in typecasting functionresult
Monday, 26 May 2025 · 2 messages
RS
Rob Stapper26 May 2025 09:56 #
Christian,
I encountered some unexpected behavior with the typecasting of functionresult. it is about the "?" in line 4 of both snippets. [expectedResult.xq], the snippet with the " ?" gives the expected result. [unexpectedResult.xq], the snipped without the "?" , gives an unexpected result.
Is this a correct observation or am I missing something?
mvgr.
Rob Stapper
CG
Christian Grün26 May 2025 10:39 #
Hi Rob,
The spec allows processors to optimize code by taking advantage the supplied type information. For example, the following code…
let $a as element() := <a/>[. = 'x']
return empty($a)…can (and will) be simplified to a static false() – both by BaseX and Saxon, and possibly other processors – because $a is typed to be a single element.
Hope this helps,
Christian
Written for BaseX 11.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery