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 29401 - [QT3] numeric-unary return type
Summary: [QT3] numeric-unary return type
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3 & XPath 3 Test Suite (show other bugs)
Version: Candidate Recommendation
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: O'Neil Delpratt
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-29 00:04 UTC by Benito van der Zander
Modified: 2016-03-04 10:14 UTC (History)
3 users (show)

See Also:


Attachments

Description Benito van der Zander 2016-01-29 00:04:02 UTC
Seems no one is looking at #23229 anymore

The QT3 also has the tests op-numeric-unary-minus-1 and op-numeric-unary-plus-1 that do not allow xs:integer where a xs:decimal is expected.
Comment 1 Abel Braaksma 2016-01-30 02:30:58 UTC
I don't think these tests are wrong, according to B.2 Operator Mapping, if the operands are of the same type (where type is xs:integer, xs:decimal, xs:float, xs:double, in that order), the result type after the calculation is applied must also be of that same type.

For this test, I believe the only possible outcome is "integer decimal float double double". What other outcome do you suggest is also valid and why?
Comment 2 Benito van der Zander 2016-01-30 10:03:13 UTC
Since integer is a subtype of decimal, every integer has the type decimal. So everywhere where a decimal occurs, you can just put an integer.

(It could be used as optimization if there is a faster evaluation path for integers)
Comment 3 Abel Braaksma 2016-01-30 21:35:55 UTC
> Since integer is a subtype of decimal, every integer has the type decimal
I agree, but I'm not sure how that influences the result in this test, I'm afraid I'm missing the point here.
Comment 4 Michael Kay 2016-01-31 16:52:30 UTC
Abel, the point is that if $X is a decimal, then we require that -$X and +$X return a decimal, but this does not preclude them returning an integer, because an integer is a decimal and therefore satisfies the requirement. But the test is written to fail if the returned value is an integer.

I have committed a change to the test to use xs:decimal(2.5) rather than xs:decimal(2) so that the question does not arise. Leaving the bug open in case others disagree.
Comment 5 O'Neil Delpratt 2016-03-04 10:14:08 UTC
I am marking this bug as resolved as we have reached our resolution