[Bug 29430] New: [FO31] Resulting type of numeric functions

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29430

            Bug ID: 29430
           Summary: [FO31] Resulting type of numeric functions
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Functions and Operators 3.1
          Assignee: mike@saxonica.com
          Reporter: abel.braaksma@xs4all.nl
        QA Contact: public-qt-comments@w3.org
  Target Milestone: ---

This bug report originated from the discussion in bug 29420, a QT3 test bug.

The question I would like to raise is what type is expected to be returned:

   fn:sum((xs:byte(1), xs:byte(2))
   fn:sum((xs:unsignedShort(12), xs:unsignedShort(24))
   fn:sum((xs:nonNegativeInteger(42), xs:nonNegativeInteger(42))

My take is that, since fn:sum is defined in terms of op:numeric-plus, section
4.2 applies and they should all return xs:integer. That does not prevent them
from return xs:byte, xs:unsignedShort, xs:nonNegativeInteger, but if an
implementation does not return those types, it should return xs:integer (and
not an xs:decimal that is itself not also an xs:integer).

Michael Kay argues in bug 29240, comment#5 that the rules in section 4.2 do not
apply for fn:sum, but I think they do.

Considering the confusion this caused, does it makes sense, and is there room,
for writing this up somehow? I.e., change this:

<quote>
The sum of a sequence of integers will therefore be an integer, while the sum
of a numeric sequence that includes at least one xs:double will be an
xs:double.
</quote>

into something like this (in particular add "of more than one"):

<quote>
The sum of a sequence of more than one integers will therefore be an integer,
while the sum of a numeric sequence that includes at least one xs:double will
be an xs:double. The sum of a singleton will always retain its type, while the
sum of an empty sequence takes the type of the second argument, or xs:integer
is absent.
</quote>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Sunday, 7 February 2016 18:39:46 UTC