<?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>9252</bug_id>
          
          <creation_ts>2010-03-16 11:00:56 +0000</creation_ts>
          <short_desc>[XQuery 1.1] Error handling in switch expression</short_desc>
          <delta_ts>2013-06-19 08:12:03 +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.0</component>
          <version>Working drafts</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="Michael Kay">mike</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</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>33612</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-03-16 11:00:56 +0000</bug_when>
    <thetext>The current draft says:

[1] A special rule applies to propagation of dynamic errors by switch expressions. 
[2] The case clauses of a switch expression do not raise any dynamic errors except in the effective case. 
[3] Dynamic errors raised in the operand expressions of the switch or the case clauses are propagated. 
[4] An implementation must not raise errors in the operand expressions of case clauses that occur after the effective case.

Some comments:

(a) it&apos;s not entirely clear exactly what it means by &quot;operand expressions&quot; and &quot;case clauses&quot;, though one can make reasonable guesses

(b) In sentence [1], I think the significance of &quot;special&quot; is that this rule overrides the general provisions in &quot;Errors and Optimization&quot;. Perhaps this should be spelled out.

(c) In [2], I think &quot;case clause&quot; is probably referring to the return expression and not the operand expressions, but this is not made clear.

(d) Rule [4] is stating an exception to rule [3]. Reading rule [3] on its own suggests that an error in any operand expression should be propagated, whether or not it comes after the effective case.

(e) Stylistically, it&apos;s odd that the subject of the four sentences is in each case a different kind of thing: respectively &quot;a rule&quot;, &quot;a case clause&quot;, &quot;an error&quot;, and &quot;an implementation&quot;.

(f) None of this applies to static errors or type errors, and this should perhaps be explicitly stated. In [1..3] the rule does say that it refers only to &quot;dynamic errors&quot;, but there is no such qualification in rule [4]; a reader might infer that type errors in cases after the effective case are not to be reported. This does raise a question about when type errors could/should/must be reported, for example in

switch ($x)
case &quot;string&quot; return &quot;a&quot;
case 42 return &quot;b&quot;
default return &quot;c&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33613</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-03-16 11:18:31 +0000</bug_when>
    <thetext>With regard to the last remark, it seems by following the link to &quot;equivalence of atomic values&quot; that the unstated intent is perhaps:

* Both the &quot;switch operand&quot; and the &quot;case operands&quot; should be atomized, and cast to string if they are untypedAtomic.

* In both cases, a type error is raised if the value contains more than one item.

* No type error is raised if the values are not comparable; they are treated as not equal.

The referenced rules for &quot;equivalence of atomic values&quot; don&apos;t really fit properly, because they assume the rules are being used in the context of grouping. For example, there&apos;s nothing that explicitly states what collation is used; it&apos;s left to the reader to work out that it can only possibly be the default collation from the static context of the switch expression.

Presumably it&apos;s reasonable to raise a warning if there is a case clause that can never fire because the types are disjoint.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33802</commentid>
    <comment_count>2</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-03-23 12:18:09 +0000</bug_when>
    <thetext>I believe these are all editorial changes rather than substantive changes - is that correct?  </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33803</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-03-23 12:26:46 +0000</bug_when>
    <thetext>I think the changes proposed are probably uncontroversial, but it&apos;s entirely possible that someone else is reading the text differently, so I think it&apos;s safest to treat it as a substantive change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35582</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-05-11 21:53:56 +0000</bug_when>
    <thetext>In today&apos;s telcon, we agreed to adopt the comments in #0 and #1, allowing the editor &quot;considerable editorial license&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36441</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-06-27 21:36:54 +0000</bug_when>
    <thetext>I am reopening this because there are one substantive issue that needs to be decided by the WG:

From the original bug report - what are the rules for reporting static errors?

&gt; (f) None of this applies to static errors or type errors, and this should
&gt; perhaps be explicitly stated. In [1..3] the rule does say that it refers only
&gt; to &quot;dynamic errors&quot;, but there is no such qualification in rule [4]; a reader
&gt; might infer that type errors in cases after the effective case are not to be
&gt; reported. This does raise a question about when type errors could/should/must
&gt; be reported, for example in
&gt; 
&gt; switch ($x)
&gt; case &quot;string&quot; return &quot;a&quot;
&gt; case 42 return &quot;b&quot;
&gt; default return &quot;c&quot;

Comment #1 raises another issue that looks substantive:

&gt; Presumably it&apos;s reasonable to raise a warning if there is a case clause that
&gt; can never fire because the types are disjoint.

However, warnings in XQuery are entirely implementation-defined, so this is not something the specification can or should address.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38457</commentid>
    <comment_count>6</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-09-03 20:23:50 +0000</bug_when>
    <thetext>At the Oxford face-to-face, the Working Group decided the following:


      We don&apos;t want to prohibit raising errors before the effective case
      but we also don&apos;t want to require them (in operands).

      We do want to prohibit errors in the operands _after_ the matching
      case.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>