#122 evaluateItem on non-singleton

v7.4
closed
5
2015-01-26
2003-02-21
Michael Kay
No

The symptom is the crash:

java.lang.IllegalStateException: evaluateItem called on
non-singleton variable reference at
net.sf.saxon.expr.VariableReference.evaluateItem(VariableReference.java:202)
at
net.sf.saxon.expr.Expression.lazyEvaluate(Expression.java:161)
at
net.sf.saxon.expr.LetExpression.iterate(LetExpression.java:45)

This occurs when the Saxon optimizer rewrites an
expression that includes a filter containing a
subexpression whose value is independent of the
context, and is potentially multi-valued, for example

$a[xyz = $nnn/@a]

where $nnn can return more than one item.

Occurs with Saxon 7.4 only.

Reported by Steve Muench.

A circumvention is to make the subexpression appear to
depend on the context, by changing it to:

$a[xyz = ./$nnn/@a]

Source code fixed - add the following method to
net.sf.saxon.expr.LetExpression.java:

public RequiredType getRequiredType() {
    return new RequiredType(sequence.getItemType(),

Type.ANY_ITEM, Cardinality.ZERO_OR_MORE);
}

Original repro is in users/muench/saxonbug, not yet
added to regression test suite.

Discussion