This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Going over the function array:sort, the second argument takes a higher order function. Such function could return an error. I wonder what is supposed to happen then. Under "Error conditions" there is no mention that array:sort fails if this function returns an error. Does this mean that if the second arg function returns an error, that such error should be ignored, and if so, it is sortable? Or can I deduct and say "it is not comparable using the le operator", so the mentioned dynamic error (no specific error code is given) applies? In the latter case it becomes a matter of definition: does the function raise an error and does that error bubble up, or does array:sort return (some) implementation-dependent error as mentioned in this section? I think I would prefer to add a line to "Error conditions". Something like: "If evaluation of $key results in an error being raised, the function array:sort fails with that error." Example (contrived): array:sort($arr, function($val) { fn:error("e:MYERR", "Some error") } )
I thought it was obvious, and is surely stated somewhere, that an expression fails with a dynamic error if evaluation of one of its operands fails with a dynamic error. But perhaps we need a general statement at the start of section 16 (higher-order functions). Certainly fn:sort is no different to any other higher-order function in this respect.
Agreed we should add a note relevant to all higher-order functions that errors thrown by the called function are propagated
I have added a note to the intro of "basic higher-order functions" explaining that errors invoked when calling the caller-supplied function are propagated.