Hi BaseX team,

I have the following simple query:

let $strings := ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')
let $arrays as array(*)* := (array{1 to 2}, array{3 to 6}, array{7 to 9})
let $arrays := sort($arrays, (), fn($seq){array:size($seq) * -1})
let $largest := $arrays => head()
return
  for $idx in $largest?* return $strings[$idx]

When I execute it with BaseX 12.2 I get the following suprising error:

[XPTY0004] One item expected, 4 found: (3 to 6).

Much more suprising is that if I wrap the $arrays?* into a trace call it works:

let $strings := ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')
let $arrays as array(*)* := (array{1 to 2}, array{3 to 6}, array{7 to 9})
let $arrays := sort($arrays, (), fn($seq){array:size($seq) * -1})
let $largest := $arrays => head()
return
  for $idx in *trace($largest?*)* return $strings[$idx]

Result:

c
d
e
f

The root cause seems to be the sort function. Because if I remove that line it works without the trace.

Best Regards,
Nico



--

Nico Kutscherauer
XML Developer

data2type GmbH
Im Breitspiel 6A
69126 Heidelberg

Tel.: +49-(0)6221-73 912 60

www.data2type.de <https://www.data2type.de>

Workingdays: Tue/Wed/Thu/Fri(HO)
Workinghours: 10-18.30

Company’s head office: Heidelberg
Commercial Register court: AG Mannheim HRB 715195
CEO: Manuel Montero Pineda

Attachment: OpenPGP_0x827D445B3AE46259.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to