<?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>20632</bug_id>
          
          <creation_ts>2013-01-10 12:33:59 +0000</creation_ts>
          <short_desc>[XP 3.0] Transitivity of subtype relationships</short_desc>
          <delta_ts>2013-01-29 16:28:48 +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>XPath 3.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://www.w3.org/Bugs/Public/show_bug.cgi?id=20643</see_also>
          <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>
          <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>81182</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-01-10 12:33:59 +0000</bug_when>
    <thetext>I think we would all agree that there is a fundamental principle that subtyping relationships need to be transitive: A&lt;:B and B&lt;:C implies A&lt;:C. Sadly this is not currently true of the subtyping rules for union types.

According to the current rules, subtype(xs:decimal, union(xs:decimal, xs:string)) is true, and subtype(xs:integer, xs:decimal) is true, but subtype(xs:integer, union(xs:decimal, xs:string)) is false.

This is clearly an oversight and should be fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81226</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-01-11 10:03:49 +0000</bug_when>
    <thetext>The relevant rules are these two:

1. Ai and Bi are AtomicOrUnionTypes, and derives-from(Ai, Bi) returns true.

2. Ai and Bi are both pure union types, and every type t in the transitive membership of Ai is also in the transitive membership of Bi.

If we fix bug #20643, then the meaning of rule 1 changes, and subtype(xs:integer, union(xs:decimal, xs:string)) becomes true. This fixes part of the problem.

The other part of the problem is that union(a, b) should be a subtype of union(A, B) if a is a subtype of A and b is a subtype of B. We can achieve this by changing rule 2 to say:

2. Ai is a pure union type, and every type t in the transitive membership of Ai satisfies subtype-itemType(t, Bi)

However, this has a side-effect which we may or may not consider desirable. The side-effect is that (for example) union(dayTimeDuration, yearMonthDuration) is now a subtype of duration, which was not the case before. Clearly it is both safe and useful that this relation should hold, but it is definitely a change in the spec. If we want to avoid introducing this side-effect, we could instead write rule 2 as:

2. Ai and Bi are both pure union types, and every type t in the transitive membership of Ai satisfies subtype-itemType(t, Bi)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81604</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2013-01-20 08:54:32 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; The relevant rules are these two:
&gt; 
&gt; However, this has a side-effect which we may or may not consider desirable.
&gt; The side-effect is that (for example) union(dayTimeDuration,
&gt; yearMonthDuration) is now a subtype of duration, which was not the case
&gt; before. 

I believe that, according to Formal Semantics, this was always the case, so shouldn&apos;t be regarded as a change, since for every value V that matches the union, V also matches duration.  So I&apos;d argue it was true in XQ1.0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81941</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2013-01-22 17:03:45 +0000</bug_when>
    <thetext>The Working Group decided to change the second of these two rules (the first two rules in the list under 2.5.6.2 The judgement subtype-itemtype(Ai, Bi)):

&lt;quote&gt;
1. Ai and Bi are AtomicOrUnionTypes, and derives-from(Ai, Bi) returns true.

2. Ai and Bi are both pure union types, and every type t in the transitive membership of Ai is also in the transitive membership of Bi.
&lt;/quote&gt;

The new wording for the second rule is:

2. Ai is a pure union type, and every type t in the transitive membership of Ai satisfies subtype-itemType(t, Bi)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82278</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2013-01-29 16:28:48 +0000</bug_when>
    <thetext>The Working Group affirmed the wording in Comment #6 today.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>