BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
694 stars 265 forks source link

Recursive function calls: Stack Overflow, XQDY0054 #2324

Closed ChristianGruen closed 2 months ago

ChristianGruen commented 3 months ago

Based on #1095: The following queries still result in StackOverflow errors:

declare variable $f := map {
  'A': function($r, $f) { $r/x ! $f?B(., $f) },
  'B': function($r, $f) { $r/x ! $f?A(., $f) }
};
$f?A(<a/>, $f)
let $even := fn($n, $self, $odd) {
  $n = 0 and $odd($n - 1, $odd, $self)
}
let $odd := fn($n, $self, $even) {
  $n != 0 or $even($n - 1, $even, $self)  
}
return $even(1, $even, $odd)
ChristianGruen commented 3 months ago

And another one that raises XQDY0054 (see https://www.mail-archive.com/basex-talk@mailman.uni-konstanz.de/msg15865.html):

declare variable $a := function-lookup(xs:QName('X'), 0);
declare variable $b := $a;
declare function local:f() { $b };
local:f()
ChristianGruen commented 2 months ago

The queries in the first comment were fixed by dcf52450ec6166db340800895bbf940427d75e8f.