Lazy evaluation of "at" variables
The Saxon XSLT and XQuery processor, developed by Saxonica
Brought to you by:
mhkay
When lazy evaluation is used for expressions that
reference positional variables (the "at" variable in a
for clause), the current value of the positional
variable is not saved, and it may therefore have the
wrong value when it is finally evaluated. For example
the following query returns "2 2" instead of "1 2":
declare function local:val($i as xs:integer) {
$i+0
};
for $v1 at $i in (1,2) order by $v1 return local:val($i)
Test case qxmp274. Fixed by putting positional
variables in an slot on the stack frame like ordinary
variables, and saving them as part of a Closure.
Michael Kay