When a FLWOR expression contains a clause such as let
$x := $y, then Saxon attempts to "optimize out" the
variable $x, replacing references to $x with references
to $y (the reason for this is mainly to simlify
expressions that the optimizer itself has constructed).
This is done incorrectly if there is a where clause or
a conditional expression as the action part of the let
Fix: in IfExpression, lines 92-93, change
thenExp = thenExp.promote(offer); elseExp = elseExp.promote(offer);
The bug is present in previous releases.
Test case added, qxmp124.xq