Bug #2173
closedNullPointerException after inlining variables
100%
Description
In a problem reported by Hans-Juergen Rennau on saxon-help list, followed up by private email, there were two occurrences of a problem that resulted from inlining of local variables:
The first two are very similar. They occur when inlining a variable declared in a FLWOR expression, for example $merge on line 51 of namesReporter.mod.xq. The inlining happens when a variable is declared and is only used once (and not in a loop): the effect is to eliminate the let clause from the FLWOR expression, and replace the variable reference by the expression to which it is bound. Before doing this, the expression is copied (the cases where this is necessary are rather obscure, but they do arise). The copy() operation is implemented separately for each expression, and it is intended to retain location information. But your query exposed two cases where location information was not being copied: the ItemChecker expression and a Switch expression (neither appear literally in the code, but are created by earlier optimizations). The location information includes a pointer to the containing function, and in the absence of this, a subsequent operation on the expression tree was failing.
Related issues
Please register to edit this issue