When variables are declared within a predicate in a union pattern in the match attribute of xsl:template, an ArrayIndexOutOfBounds exception occurs with the signature index of -999. This exception always indicates that a variable reference is being evaluated at run-time when no slot was allocated to the variable at compile time.
This occurs with a template rule such as
match="a[some $x in S satisfies $x = 23] | b[some $x in S satisfies $x = 23]"
It can also occur when the variables were not present in the original pattern as written, but have been introduced by the optimizer. The basic bug is present in previous releases and in Saxon-B. but is much more likely to manifest itself as a result of the optimizations done by Saxon-SA 9.0.
A patch is being placed in Subversion - modules net.sf.saxon.style.StyleElement, net.sf.saxon.pattern.Pattern, and net.sf.saxon.pattern.UnionPattern