[Bug 5671] [FO] Type promotion in fn:min and fn:max

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5671





------- Comment #2 from jmdyck@ibiblio.org  2008-05-20 20:10 -------
So I believe the implication is that the XQTS test K2-SeqMINFunc-15 is correct.
That is,
    min(xs:unsignedShort(<e>1</e>)) instance of xs:unsignedShort
yields
    true

But what about something like
    min((xs:unsignedShort(<e>1</e>), xs:positiveInteger(<e>2</e>)))
    instance of xs:unsignedShort
?

The least common supertype of xs:unsignedShort and xs:positiveInteger is
xs:nonNegativeInteger, so the text suggests that the two items in the input
sequence are converted to xs:nonNegativeInteger by subtype substitution,
yielding a 'converted sequence' consisting of two xs:nonNegativeInteger values,
one of which is returned as the result of the fn:min call, which then fails the
"instance of" test (i.e. yielding false for the whole expr).

However, XQuery 2.5.4 (SequenceType Matching) says:
    Subtype substitution does not change the actual type of a value.
    For example, if an xs:integer value is used where an xs:decimal
    value is expected, the value retains its type as xs:integer.
In terms of the example, if an xs:unsignedShort value is used where an
xs:nonNegativeInteger is expected, the value retains its type as
xs:unsignedShort. This suggests that the result of the fn:min call is actually
an xs:unsignedShort value, and the "instance of" test yields true.

Received on Tuesday, 20 May 2008 20:11:35 UTC