Saxon-EE produces the warning
Recovering from internal error: Base value for indexed lookup is not indexable
This is not fatal - Saxon recovers successfully - but it shows that something has gone wrong during the optimization and the execution may well be inefficient.
In this particular instance the problem happened during inlining of a function or variable; during the copying of part of the expression tree, the information that an index for a particular local variable was required was not transferred to the copied subtree. A patch has been created.
The same symptom could occur as a result of other optimization problems.