When the sum() function is used inside a predicate,
and the predicate also contains a variable reference,
then the sum() function will give the wrong answer.
Example: order[sum(item/@price) > $limit]
This is a bug in the expression reduction that occurs
when a predicate contains a variable (or some other
conditions, e.g. a call on current()). It also happens
in some contexts other than predicates, for example
sort keys. The sum() function is wrongly rewritten,
and thus evaluated, as a count() function.
Present in all previous releases.
Spotted by MHK when reading the code!