An IntegerRangeTest is an expression representing a construct of the form (X = Y to Z). If an IntegerRangeTest appears inside a repeatedly-executed expression (for example, the return clause of a "for" expression, or a predicate in a filter expression), and if any of the subexpressions X, Y, or Z contain references to an expression that is lifted out of the loop because it is independent of the range variable or context item, then an internal error occurs, for example:
*** Internal Saxon error: local variable encountered whose binding has been deleted Variable name: sr
A patch is being committed on both the 9.0 and 9.1 branches. The problem probably affects earlier releases as well.
Test case added to xqts-extra: filter-004.xq