<?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>29173</bug_id>
          
          <creation_ts>2015-10-02 14:56:13 +0000</creation_ts>
          <short_desc>[QT3TS] xs-error tests expecting XPTY0004</short_desc>
          <delta_ts>2015-10-14 13:13:49 +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>XQuery 3 &amp; XPath 3 Test Suite</component>
          <version>Candidate 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="Debbie Lockett">debbie</reporter>
          <assigned_to name="Tim Mills">tim</assigned_to>
          <cc>debbie</cc>
    
    <cc>mike</cc>
    
    <cc>tim</cc>
          
          <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>123451</commentid>
    <comment_count>0</comment_count>
    <who name="Debbie Lockett">debbie</who>
    <bug_when>2015-10-02 14:56:13 +0000</bug_when>
    <thetext>The following tests expect error code XPTY0004, but should the error be FORG0001?

xs-error-009   xs:error(xs:untypedAtomic(&quot;&quot;))

xs-error-010   xs:error(&quot;&quot;)

xs-error-011   xs:error(1.0)

xs-error-012   xs:error(1e0)

xs-error-013   xs:error(1)

xs-error-014   xs:error(1) instance of xs:error

xs-error-032   xs:error(1) castable as xs:error

xs-error-033   xs:error(1) castable as xs:integer

xs-error-039   xs:error(1) cast as xs:error

xs-error-043   xs:error(1) instance of xs:error

xs-error-045   typeswitch (xs:error(1)) 
               case xs:error return fn:true()
               default return false()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123452</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-02 15:08:26 +0000</bug_when>
    <thetext>Rationale on this: the xs:error function is defined to be equivalent to casting to a union type with no member types. This takes you to 19.3 (casting to union types), which takes you to 19.2.2. This defines the cast in terms of validation. Validation fails, because the value space is empty. Except where otherwise specified, validation failures result in FORG0001.

The significance of this is that calling xs:error() produces a dynamic error rather than a type error, which makes it safe to use for deliberate signalling of a dynamic error in a branch of a conditional. Indeed F+O section 18.4 explicitly says that casting to xs:error will always fail with a *dynamic* error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123453</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-02 15:16:37 +0000</bug_when>
    <thetext>The above rationale applies when the supplied value is a string or untypedAtomic. When it is any other type, e.g. integer, the relevant rule is in 19.3.5 casting to a union type: 

&quot;If none of these conditions applies, the cast fails with a dynamic error [err:FORG0001].&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123657</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2015-10-12 09:23:15 +0000</bug_when>
    <thetext>Could you please confirm which of the rules under point 5 of 3.18.3 Cast?

I can see that 

(c) cast is supported if the target type is a non-primitive atomic type and the input type is xs:string or xs:untypedAtomic.

applies in some of these cases, but not (for example) in xs-error-011.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123658</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-12 09:42:50 +0000</bug_when>
    <thetext>XQuery 3.18.3 refers to F+O section 19 as the normative specification, so I tend to largely ignore it. It doesn&apos;t seem to handle the case of casting to a union type from a type other than string/untypedAtomic. I&apos;ll raise a bug on that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123660</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-12 09:49:13 +0000</bug_when>
    <thetext>I have raised bug #29192 against the XPath and XQuery specs: their non-normative summary of the casting rules is incomplete.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123671</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2015-10-13 11:51:51 +0000</bug_when>
    <thetext>Test cases updated.

BTW, it would be nice to add a dependency other than XSD 1.1 for this, in view of the note:

   &lt;!-- NOTE: An implementation supporting XSD 1.1 must support xs:error,
              however it is not an error for an implementation not supporting 
              XSD 1.1 to support xs:error. --&gt;


Please mark as CLOSED if you agree with the resolution.  Otherwise, REOPEN.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123709</commentid>
    <comment_count>7</comment_count>
    <who name="Debbie Lockett">debbie</who>
    <bug_when>2015-10-14 13:13:49 +0000</bug_when>
    <thetext>Thanks, closing.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>