Project

Profile

Help

Bug #6102

closed

Various QT4 functions do not accept () as value for optional arguments

Added by Michael Kay about 1 year ago. Updated 5 months ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
Features new in 4.0
Sprint/Milestone:
-
Start date:
2023-06-28
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
trunk
Fix Committed on Branch:
trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

In many cases where an argument is optional, the 4.0 specifications allow an empty sequence to be supplied as the value, with the same effect as omitting the argument. In a number of cases this change has not been implemented.

Examples so far identified include:

fn:resolve-uri (2nd arg)
fn:subsequence (3rd arg)
fn:substring (3rd arg)
fn:tokenize (2nd arg)
fn:trace (2nd arg)
fn:unparsed-text (2nd arg)
fn:unparsed-text-available (2nd arg)
fn:unparsed-text-lines (2nd arg)
array:subarray
Actions #1

Updated by Michael Kay about 1 year ago

I've implemented a raft of such changes in respect of the collation argument to various functions, and have added test cases for these. This will go into 12.4.

Actions #2

Updated by Michael Kay 12 months ago

Further examples: regex functions such as matches() and replace() allow the flags to be an empty sequence.

We should probably run a diff over the function signatures to get a complete list at some stage.

Actions #3

Updated by Michael Kay 12 months ago

I've implemented a number of these changes, and have added tests - but it's hard to know when the process is complete.

The way forward might be to add a unit test that takes the function catalog as input and tests each function in the specification to see if we have a matching implementation.

Actions #4

Updated by Michael Kay 12 months ago

I have created a unit test internalTests/SignatureTests that checks the signature in the function catalog against the implementation. Initial results:

Wrong return type for fn:format-integer#2
Wrong return type for fn:format-integer#3
Wrong type for argument 3 of fn:format-number#3
Wrong type for argument 2 of math:pow#2
Wrong type for argument 3 of fn:compare#3
Wrong type for argument 2 of fn:substring#2
Wrong type for argument 2 of fn:substring#3
Wrong type for argument 3 of fn:substring#3
Wrong type for argument 3 of fn:contains#3
Wrong type for argument 3 of fn:starts-with#3
Wrong type for argument 3 of fn:ends-with#3
Wrong type for argument 3 of fn:substring-before#3
Wrong type for argument 3 of fn:substring-after#3
Wrong type for argument 3 of fn:matches#3
No entry found for fn:replace#5
Wrong type for argument 2 of fn:tokenize#2
Wrong type for argument 2 of fn:tokenize#3
Wrong type for argument 3 of fn:tokenize#3
Wrong return type for fn:analyze-string#2
Wrong return type for fn:analyze-string#3
Wrong type for argument 3 of fn:contains-token#3
No entry found for fn:parts#0
Wrong type for argument 1 of fn:namespace-uri-for-prefix#2
Unknown type map(union(xs:NCName, enum('')), xs:anyURI)
Wrong return type for fn:in-scope-namespaces#1
Wrong type for argument 1 of fn:in-scope-namespaces#1
Wrong return type for fn:has-children#1
Wrong type for argument 3 of fn:index-of#3
Wrong type for argument 2 of fn:distinct-values#2
Wrong type for argument 2 of fn:remove#2
Wrong type for argument 2 of fn:replicate#2
No entry found for fn:truncate#1
Wrong type for argument 2 of fn:subsequence#2
Wrong type for argument 2 of fn:subsequence#3
Wrong type for argument 3 of fn:subsequence#3
No entry found for fn:range-from#2
No entry found for fn:range-to#2
Wrong type for argument 3 of fn:deep-equal#3
No entry found for fn:differences#2
No entry found for fn:differences#3
No entry found for fn:differences#4
Wrong type for argument 2 of fn:max#2
Wrong type for argument 2 of fn:min#2
Wrong return type for fn:sum#1
Wrong type for argument 2 of fn:unparsed-text#2
Wrong type for argument 2 of fn:unparsed-text-lines#2
Wrong type for argument 2 of fn:unparsed-text-available#2
Wrong return type for fn:parcel#1
Wrong return type for fn:parse-xml#1
Wrong return type for fn:current-dateTime#0
Wrong type for argument 1 of fn:op#1
Wrong return type for map:find#2
Wrong return type for map:filter#2
Wrong type for argument 2 of map:filter#2
No entry found for map:replace#3
No entry found for map:substitute#2
No entry found for map:group-by#2
Wrong return type for fn:collation-key#1
Wrong return type for fn:collation-key#2
Wrong type for argument 2 of fn:collation-key#2
Wrong return type for fn:json-to-xml#1
Wrong return type for fn:json-to-xml#2
No entry found for fn:json#1
No entry found for fn:json#2
Wrong type for argument 2 of array:put#3
Wrong type for argument 3 of array:replace#3
Wrong type for argument 3 of array:subarray#3
Wrong return type for array:slice#4
Wrong type for argument 1 of array:slice#4
Wrong type for argument 2 of array:insert-before#3
Wrong return type for array:for-each#2
Wrong return type for array:for-each-pair#3
No entry found for array:from-sequence#1
No entry found for array:from-sequence#2
Wrong return type for array:members#1
No entry found for array:of#1
No entry found for array:partition#2
Unknown type item-type(rng)
Wrong return type for fn:random-number-generator#0
Unknown type item-type(rng)
Wrong return type for fn:random-number-generator#1
No entry found for fn:all#2
No entry found for fn:stack-trace#0
Wrong type for argument 2 of fn:all-equal#2
Unknown type xs:anyAtomicType**
Wrong type for argument 1 of fn:all-different#1
Unknown type xs:anyAtomicType**
Wrong type for argument 1 of fn:all-different#2
Wrong type for argument 2 of fn:all-different#2

expected: <0> but was: <84>

Actions #5

Updated by Michael Kay 12 months ago

This exercise has revealed quite a few unintended discrepancies between the spec and the implementation, e.g. functions that are declared (in the implementation) with too "wide" a return type, which is likely to cause unnecessary dynamic type checking. There are also some discrepancies that are deliberate, for example Saxon declares the argument type for the "start" and "length" arguments of substring() as xs:numeric rather than xs:double, to avoid unnecessary conversion from integer to double and back again when the supplied arguments are integers. The test will somehow have to take account of this.

Actions #6

Updated by Michael Kay 12 months ago

I've fixed most of these by either:

  • correcting the type in the function tables (e.g. XPath40FunctionSet)
  • adding to an exception list where the implemented type is knowingly different from the type in the spec -- for example for substring we choose to declare the type as xs:numeric rather than xs:double.

The remaining cases are as follows, and mostly represent changes in the 4.0 spec that have not yet been implemented:

No entry found for fn:log#2
Wrong type for argument 3 of fn:format-number#3
No entry found for fn:replace#5
Wrong type for argument 3 of fn:analyze-string#3
Wrong type for argument 1 of fn:in-scope-namespaces#1
No entry found for fn:void#1
Wrong type for argument 4 of fn:deep-equal#4
No entry found for fn:parse-html#2
Wrong return type for fn:transitive-closure#3
Wrong type for argument 1 of map:of-pairs#2
No entry found for map:values#1
No entry found for map:pair#2
Wrong type for argument 2 of map:filter#2
No entry found for map:replace#3
No entry found for map:substitute#2
Wrong return type for fn:json-to-xml#2
No entry found for fn:parse-csv#2
No entry found for fn:csv-to-xdm#2
No entry found for fn:csv-to-xml#2
No entry found for fn:csv-fetch-field-by-column#3
No entry found for fn:json#2
No entry found for array:split#1
No entry found for array:values#1
No entry found for fn:stack-trace#0
Wrong type for argument 2 of fn:parse-uri#2
Actions #7

Updated by Michael Kay 12 months ago

  • Status changed from New to In Progress
Actions #8

Updated by Michael Kay 5 months ago

  • Status changed from In Progress to Resolved
  • Applies to branch trunk added
  • Fix Committed on Branch trunk added
  • Platforms .NET, Java added

Marking this as resolved, although tracking changes to the function signatures in the specs is a never-ending task.

Please register to edit this issue

Also available in: Atom PDF