In XQuery Update, if an expression within an updating function uses an updating subexpression in a context where it is not allowed, the compiler does not detect the error. The error may go undetected, or it might result in an UnsupportedOperationException at run-time.
An example is to use
let $x := delete //s
which is an error because the right-hand-side of ":=" must not be an updating expression. The error is detected if this FLWOR expression appears at the top level of an updating (or non-updating) query, but it is not detected if it appears as the body of an updating function.
A patch is being raised in the Saxon-SA subversion source.