#401 AssertionError: Value of variable is undefined (null)

v8.5
closed
nobody
5
2012-10-08
2005-08-22
Michael Kay
No

Symptom: run-time exception

AssertionError: Value of variable is undefined (null)

This is an optimizer bug associated with expressions of
the form exp[position() = $x], though the precise form
may vary.

When an expression is rewritten to use an internal
construct called a PositionRange, the dependencies on
its subexpressions are not set up correctly, which
means that when the system decides to evaluate the
expression lazily, the variables it depends on are not
saved in the Closure.

Fix: add the following method to
net.sf.saxon.expr.PositionRange:

public Iterator iterateSubExpressions() {
    return new PairIterator(minPosition, maxPosition);
}

A check of the class hierarchy shows there are two
other classes that also lack implementations of this
method. In net.sf.saxon.expr.IntegerRangeTest, add:

public Iterator iterateSubExpressions() {
Expression[] e = {value, min, max};
return Arrays.asList(e).iterator();
}

and in net.sf.saxon.instruct.Doctype, add

public Iterator iterateSubExpressions() {
    return new MonoIterator(content);
}

Michael Kay

Discussion

  • Kevin Rodgers
    Kevin Rodgers
    2005-08-23

    Logged In: YES
    user_id=662991

    Your source code almost always includes a short comment
    before each method -- what do you use to describe these
    iterateSubExpression methods?

    Thanks,

    Kevin

     
  • Michael Kay
    Michael Kay
    2005-08-23

    Logged In: YES
    user_id=251681

    I tend to assume people applying patches aren't too worried
    about comments, but if you want you can copy the method
    description from the superclass
    net.sf.saxon.expr.ComputedExpression

    Michael Kay