basex icon indicating copy to clipboard operation
basex copied to clipboard

Recursive function items: Typing

Open ChristianGruen opened this issue 1 year ago • 1 comments

Caused at runtime by tail-call optimizations:

let $f := fn($p, $self) as xs:integer {
  if((1 to 10000)[$p + 1] <= 5000) then $self($p + 1, $self) else $p
}
return $f(1, $f)

Expected: 5000 Result: [XPTY0004] Cannot convert empty-sequence() to xs:integer: ().

ChristianGruen avatar Jul 12 '24 13:07 ChristianGruen

Possibly related:

let $a := %basex:inline(0) fn($f) as element() { $f() }
return $a(fn() { <xml/> })

Expected: <xml/> Returned: [XPTY0004] Cannot convert empty-sequence() to element(): ().

→ This one has been fixed by a recent commit.

ChristianGruen avatar Jul 12 '24 14:07 ChristianGruen