Hi Hans-Jürgen, Thanks for the observation. A simplified version of your query is:
let $a := 'x' let $b := if($a) then (<a/>, <b/>) else error() return $b/name() The problem has been fixed in the latest snapshot [1]. Best, Christian [1] https://files.basex.org/releases/latest/ On Wed, Apr 9, 2025 at 8:29 PM Hans-Juergen Rennau <[email protected]> wrote: > Dear BaseX people, > > I have encountered a bug (?). Please consider this code: > > = = = = = = = = = begin = = = > > declare namespace f="http://weatherreport.org/heavyweather"; > > declare function f:relatedNames($node, $relationship) as xs:string* { > let $fnName := > function($node) { > let $_DEBUG := trace(count($node), '#node: ') > return name($node)} > > let $items := > switch($relationship) > case 'child' return $node/* > default return error() > return > $items/$fnName(.) => distinct-values() => sort() => string-join(', > ') > }; > > let $doc := <doc><a/><b/><c/></doc> > return f:relatedNames($doc, 'child') > > = = = = = = = = = end = = = > > = = = = = = = = = output = = = > #node: 3 > Stopped at C:/projects/foxpath-examples/pre-balisage/problem-basex2.xq, > 15/25: > [XPTY0004] Item expected, sequence found: (<a/>, <b/>, <c/>). > = = = = = = = = = = = = = = = = > > The call $fnName(.) receives a single item, but three items arrive at the > function item! > > With kind regards, > Hans-Jürgen > > PS: The funny switch() seems to play a part in the game, when I removed > it, the issue vanished. > PPS: BaseX 11.8 [Standalone] > >

