[Bug 29420] [QT3] K2-SeqSUMFunc-4 and xs:unsignedShort vs xs:integer result

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

--- Comment #6 from Abel Braaksma <abel.braaksma@xs4all.nl> ---
(In reply to Michael Kay from comment #5)
> The statement in 4.2 is clearly intended to apply only to the operators in
> the table immediately above, such as op:numeric-plus. It clearly doesn't
> apply to all two-arguments functions.
Then I'm lost, because fn:sum I believe is (normatively) defined in terms op
op:numeric-plus, and as shown in the example, it seems that current practice of
(some?) implementations is that derived types are unified into xs:integer if
that is their common ancestor, even if the types of the sequence are all the
same.

Personally, I do not see much use in fn:sum with xs:byte or xs:short to have to
retain its type, if not only because of the possible overflow scenarios, which
in turn are defined by that same section 4.2, adding to the confusion if that
is supposed to be different.

Something can be said for positive-only types, or negative-only types to keep
their type identity, but again, to me it makes sense if they would all simply
return xs:integer for the sake of uniformity and principle of least surprise
(but that is in the eye of the beholder, of course).

------------------------------

That said, I think I digressed in the direction of non-singleton sequences and
forgot the point of the original bug report. I see now that it should return
itself and it makes sense (to some extend at least) that is should retain its
type, which means that fn:sum($somesingleton) is the same as $somesingleton.

However, the text here seems to contradict itself:

<quote>
For numeric values, the numeric promotion rules defined in 4.2 Arithmetic
operators on numeric values are used to promote all values to a single common
type. 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>

This is not in line with the given function body expression. I have reported
this separately in Bug 29430.

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

Received on Sunday, 7 February 2016 18:42:40 UTC