<?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>29813</bug_id>
          
          <creation_ts>2016-09-08 18:43:20 +0000</creation_ts>
          <short_desc>[xslt30] Errors in accumulators</short_desc>
          <delta_ts>2016-09-30 10:14:37 +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>XSLT 3.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</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="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>127342</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-09-08 18:43:20 +0000</bug_when>
    <thetext>We briefly touched on the subject of dynamic errors in evaluating an accumulators today, and it occurred to me that the spec has very little to say on the topic. Since accumulators are evaluated &quot;in the background&quot;, it is not clear how a dynamic error should be handled, or whether it can be caught.

I propose that a dynamic error that occurs while evaluating xsl:accumulator/@initial-value or xsl:accumulator-rule/@select should (only) cause a &quot;subsequent&quot; call on accumulator-before() or accumulator-after() to fail with (the same) dynamic error. In other words, the error is &quot;held back&quot; until the next time the accumulator is referenced (and by implication it goes unreported if the accumulator is not subsequently referenced).

This fits well with a lazy evaluation strategy. If an accumulator is evaluated in a parallel thread to the main processing then the accumulator thread must hold on to the error until the time comes to report it. Dynamic errors become capable of a predictable try/catch behaviour.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127355</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-09-09 18:25:31 +0000</bug_when>
    <thetext>Subject to WG approval, I have added the following text to resolve this:

&lt;div3 id=&quot;errors-in-accumulators&quot; diff=&quot;add&quot; at=&quot;T-bug29813&quot;&gt;
&lt;head&gt;Dynamic Errors in Accumulators&lt;/head&gt;
&lt;p&gt;If a dynamic error occurs when evaluating the &lt;code&gt;initial-value&lt;/code&gt; expression of &lt;elcode&gt;xsl:accumulator&lt;/elcode&gt;, or the &lt;code&gt;select&lt;/code&gt; expression of &lt;elcode&gt;xsl:accumulator-rule&lt;/elcode&gt;, then the error is signaled as an error from the next call on &lt;function&gt;accumulator-before&lt;/function&gt; or &lt;function&gt;accumulator-after&lt;/function&gt; that references the accumulator. If no such call on &lt;function&gt;accumulator-before&lt;/function&gt; or &lt;function&gt;accumulator-after&lt;/function&gt; happens, then the error goes unreported.&lt;/p&gt;
               
&lt;note&gt;&lt;p&gt;In the above rule, the word &lt;term&gt;next call&lt;/term&gt; is to be understood in terms of functional dependency; that is, a call to &lt;function&gt;accumulator-before&lt;/function&gt; or &lt;function&gt;accumulator-after&lt;/function&gt; signals in error if the accumulator value is functionally dependent on a computation that fails with a dynamic error.&lt;/p&gt;&lt;/note&gt;
               
&lt;note&gt;&lt;p&gt;Particularly in the case of streamed accumulators, this may mean that the implementation has to &quot;hold back&quot; the error until the next time the accumulator is referenced, to give applications the opportunity to catch the error using &lt;elcode&gt;xsl:try&lt;/elcode&gt; and &lt;elcode&gt;xsl:catch&lt;/elcode&gt; in a predictable way.&lt;/p&gt;&lt;/note&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127370</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-09-12 16:19:12 +0000</bug_when>
    <thetext>Note one consequence of this rule: in test stream-203, a type error occurs putting a value in a map while applying xsl:accumulator-rule/@select, and the error is deferred until accumulator-before() is called. But this call occurs while evaluating the predicate of a match pattern, which masks the error; so it goes unreported, leading to difficulty in diagnostics.

(However, Saxon gives a warning when an error occurs matching a pattern, so all is not lost.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127613</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-09-30 10:14:37 +0000</bug_when>
    <thetext>The WG approved the change, with two observations that have been applied:

(a) there was no mention of the change in Appendix L

(b) it&apos;s worth a note to mention that errors in xsl:accumulator-rule/@match are covered by the general rules on errors in patterns in section 5.5.4</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>