This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29758 - [FO31] What is the sort order of errors?
Summary: [FO31] What is the sort order of errors?
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-28 10:50 UTC by Abel Braaksma
Modified: 2016-12-16 19:55 UTC (History)
0 users

See Also:


Attachments

Description Abel Braaksma 2016-07-28 10:50:31 UTC
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") } )
Comment 1 Michael Kay 2016-07-28 11:52:15 UTC
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.
Comment 2 Michael Kay 2016-09-06 15:36:27 UTC
Agreed we should add a note relevant to all higher-order functions that errors thrown by the called function are propagated
Comment 3 Michael Kay 2016-09-06 19:55:07 UTC
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.