When the current() function is used within a predicate within the pattern in an attribute of an XSLT instruction that is contained within a loop, Saxon can fail with an error message along the lines of:
*** Internal Saxon error: local variable encountered whose binding has been deleted Variable name: saxon:current21662929
This affects any pattern held in an attribute of an instruction: specifically the count and from attributes of xsl:number, and the group-starting-with and group-ending-with attributes of xsl:for-each-group. The error occurs if the instruction is contained within an xsl:for-each or similar looping construct. It happens because the variable representing the current() function is not recognized as having a value that changes with each iteration of the loop, and is therefore incorrectly lifted out of the loop by the optimizer. Affects Saxon 9.2 and probably earlier releases; a patch for the 9.2 branch is being committed to Subversion.