[FIX] XQuery, detect impossible casts/promotions of expressions before
      they are removed. Closes #865.
[FIX] XQuery: show similar function name if function is not found