<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>5261</bug_id>
          
          <creation_ts>2007-11-09 08:46:16 +0000</creation_ts>
          <short_desc>[FO] errors in cast vs. construction</short_desc>
          <delta_ts>2008-03-11 13:29:21 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Functions and Operators 1.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>17646</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2007-11-09 08:46:16 +0000</bug_when>
    <thetext>XQTS contains two similar tests, K2-SeqExprCast-248

xs:integer(xs:float(&quot;INF&quot;))

which expects error FORG0001 (Invalid value for cast/constructor)

and CastAs180

xs:float(&quot;INF&quot;) cast as xs:integer

which expects error FOCA0002 (Invalid lexical value).

Since construction and casting both normalize to the same form, these should surely expect the same error.  Personally, I&apos;d favour FORG0001.

Relevant areas of the specification are:

http://www.w3.org/TR/xquery-operators/#casting-to-numerics
17.1.3.3 Casting to xs:decimal
17.1.3.4 Casting to xs:integer

&quot;If SV is one of the special xs:float or xs:double values NaN, INF, or -INF, an error is raised [err:FOCA0002].&quot;

and

http://www.w3.org/TR/xquery/#id-cast

&quot;If casting from the input type to the target type is supported but nevertheless it is not possible to cast the input value into the value space of the target type, a dynamic error is raised. [err:FORG0001] This includes the case when any facet of the target type is not satisfied. For example, the expression &quot;2003-02-31&quot; cast as xs:date would raise a dynamic error.&quot;

Note that the latter does not even mention the possibility of FOCA0002.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18295</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2008-01-15 00:34:19 +0000</bug_when>
    <thetext>The casting section of the XQuery book states &quot;A summary of the rules are listed below  the normative definition of these rules is given in [XQuery 1.0 and XPath 2.0 Functions and Operators].&quot; So it&apos;s clear that the F+O definition is intended to take precedence. Whether we want to modify the text to align it at the level of defining error codes, I don&apos;t know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18304</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2008-01-15 10:20:28 +0000</bug_when>
    <thetext>I&apos;ve changed our implementation to throw FOCA0002 in this case.  The expected error is now correct in CVS, however our implementation disagress with the expected error code (FORG0001) for K2-SeqExprCast-254 to K2-SeqExprCast-331.

These cases are of the form:

some-type-derived-from-integer(xs:float(&quot;-INF&quot;))

where some-type-derived-from-integer includes xs:byte, xs:nonPositiveInteger, negativeInteger etc.

I&apos;ll report these as errors against XQTS.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>19404</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2008-03-11 13:24:32 +0000</bug_when>
    <thetext>At the joint WG meeting on 2008-03-04, it was decided to change the language book to delete references to specific F&amp;O error codes in the casting section, to remove conflicts and the potential for conflict. The language book already says that the F&amp;O specification of casting is the normative one.

I am changing the resolution to FIXED. Tim Mills, as the originator, if you agree with this resolution please change the status to CLOSED.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>19405</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2008-03-11 13:29:21 +0000</bug_when>
    <thetext>Thanks.  Hopefully this can now be reflected in XQTS (Bug 5363).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>