A NullPointerException can occur in the method SingletonAtomizer.getItemType(). The problem occurs after a variable has been inlined because there is only a single reference (and the reference is not in a loop), for example
let $t := ....some expression.... return f($t)
It occurs because an expression is constructed that has no link to its "container". Two patches are being placed in Subversion:
(a) a patch that ensures that this particular optimization rewrite sets the container of the new expression correctly
(b) a patch that makes the SingletonAtomizer class resilient to the situation where the container of an expression is not set.