<?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>30377</bug_id>
          
          <creation_ts>2018-12-17 20:43:54 +0000</creation_ts>
          <short_desc>[XSLT30] Merge keys with NaN and empty-sequence() cause non-deterministic behavior</short_desc>
          <delta_ts>2019-02-20 09:51:25 +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>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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="Abel Braaksma">abel.online</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>129451</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2018-12-17 20:43:54 +0000</bug_when>
    <thetext>We define the process of sorting merge input in reference to the xsl:sort process, which defines NaN to be equal to itself and empty-sequence() to be equal to itself, but preceding any other item.

This works fine for sorting, but in the text of how a merge-group is formed, we define that in terms of the &apos;eq&apos; operator (section 15.7):

&quot;Generally, two sets of merge key values are distinct if any corresponding items in the two sets of values do not compare equal under the rules for the XPath eq operator...&quot;

But under the eq operator, NaN is not equal to itself and comparing anything to the empty-sequence yields the empty sequence. Therefore, under the current rules, one NaN is distinct from another NaN in a merge-group (and therefore wouldn&apos;t end up in the same group), but not when sorting.

This is problematic, since the current-merge-group should be equal to what is considered equal during the sorting process.

I think the intent of the text is clear (empty-sequence() is grouped together, and so is NaN), but I&apos;d propose to add a clarification for these edge cases (or refer back to the sorting process, something like: what is equal during sorting ends up in the same bucket).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129498</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-02-13 15:51:49 +0000</bug_when>
    <thetext>I think we should resolve this by delegating more strongly to the xsl:sort rules, especially §13.1.2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129542</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-02-20 09:51:25 +0000</bug_when>
    <thetext>A proposed erratum E39 has been drafted and was published on 13 Feb 2019, HTML version: https://htmlpreview.github.io/?https://github.com/w3c/qtspecs/blob/master/errata/xslt-30/html/xslt-30-errata.html#E39

I would like to discuss the erratum, it seems to cover and fix my concern but I&apos;m unsure if it covers the full range of cases, perhaps because we use negation (do not compare equal under the &apos;eq&apos; operator). The stronger reference to the xsl:sort section definitely helps.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>