<?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>5254</bug_id>
          
          <creation_ts>2007-11-06 10:48:15 +0000</creation_ts>
          <short_desc>[FS] Validate has inconsistent static and dynamic types</short_desc>
          <delta_ts>2009-02-16 07:42:50 +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>Formal Semantics 1.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</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="Nick Jones">nick</reporter>
          <assigned_to name="Michael Dyck">jmdyck</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>17606</commentid>
    <comment_count>0</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2007-11-06 10:48:15 +0000</bug_when>
    <thetext>In FS 4.13 the static type analysis for validate expressions can only ever be a union of element types.

But in FS 4.13.2 the validate expression can yield a document rather than an element.

I think the fix would be to split the static type analysis rule into two. One for elements, the other for documents.

statEnv |-  Expr : Type
statEnv |-  Type &lt;: (element)
statEnv |-  prime(Type) = ElementType1 | ... | ElementTypen
.
(same as current rule)
.
statEnv |-  validate ValidationMode { Expr } : Type1


statEnv |-  Expr : Type
statEnv |-  Type &lt;: (document {ElementType})
statEnv |-  prime(ElementType) = ElementType1 | ... | ElementTypen
.
(same as current rule)
.
statEnv |-  validate ValidationMode { Expr } : document {Type1}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18407</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-01-18 06:54:31 +0000</bug_when>
    <thetext>I agree that there&apos;s a problem, and I agree with your approach to a solution.
However, the original rule has some additional bugs that also need to be fixed:

1. The type &apos;element&apos; should be &apos;element *&apos;. (See Bug 3269.)

2. The earlier and later occurrences of ElementTypei should be distinct.

3. Requiring Type &lt;: document { ElementType } is too restrictive, because
   ElementType cannot be bound to a type involving
   (a) processing-instruction or comment types, or
   (b) a union of element types.

Points 1, 2, and 3a are all easy to fix, but I&apos;m not sure what to do about 3b.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18454</commentid>
    <comment_count>2</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2008-01-22 13:06:21 +0000</bug_when>
    <thetext>&gt; 3. Requiring Type &lt;: document { ElementType } is too restrictive, because
&gt;    ElementType cannot be bound to a type involving
&gt;    (a) processing-instruction or comment types, or
&gt;    (b) a union of element types.
&gt; 
I think &quot;ElementType&quot; isn&apos;t actually an ElementType, it was just an unfortunately chosen name. If it is changed to &quot;Type_Element&quot; or something then I think the rule is valid.

The prime(Type_Element) = ElementType1 | .... | ElementTypen should cover the union case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18460</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-01-22 18:02:02 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; I think &quot;ElementType&quot; isn&apos;t actually an ElementType, it was just an
&gt; unfortunately chosen name.

That could be, though I somewhat doubt it.

&gt; If it is changed to &quot;Type_Element&quot; or something then I think
&gt; the rule is valid.
&gt; 
&gt; The prime(Type_Element) = ElementType1 | .... | ElementTypen should cover the
&gt; union case.

But then:
1) It incorrectly allows multiple elements in the document content.
2) It doesn&apos;t allow processing-instructions or comments.
3) Given a binding for Type_Element that satisfies the rule, there are (infinitely?) many supertypes of it (and possibly some subtypes of it) that also satisfy the rule, and that lead to different types for the validate expression.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23363</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-01 00:31:14 +0000</bug_when>
    <thetext>It occurred to me that splitting FS 4.13 / STA / rule 1 into a rule for
    Type &lt;: element
and a rule for
    Type &lt;: document { ... }
woldn&apos;t allow for a Type that was a union of (subtypes of) those two
possibilities.  After some thought, I&apos;m instead proposing to replace that
rule with the following set of rules (leaving out &quot;statEnv |-&quot; here for
brevity), which I think handle all problems raised above.

    Expr : Type
    Type &lt;: element * |
            document { element * &amp; (processing-instruction * | comment)* }
    Type with mode ValidationMode unites to TypeU
    ----------------------------------------------------
    validate ValidationMode { Expr } : TypeU


    prime( Type ) = FormalItemType1 | ... | FormalItemTypen
    FormalItemType1 with mode ValidationMode resolves to FormalItemType1&apos;
    ...
    FormalItemTypen with mode ValidationMode resolves to FormalItemTypen&apos;
    FormalItemType1&apos; | ... | FormalItemTypen&apos; = TypeU
    ----------------------------------------------
    Type with mode ValidationMode unites to TypeU


    DocumentType = document { Type }
    Type with mode ValidationMode unites to TypeU
    ----------------------------------------------------
    DocumentType with mode ValidationMode resolves to document { TypeU }


    ElementType = element ElementNameOrWildcard OptTypeSpecifier
    ElementNameOrWildcard with mode ValidationMode resolves to ElementType&apos;
    ----------------------------------------------------
    ElementType with mode ValidationMode resolves to ElementType&apos;


    ----------------------------------------------------
    ProcessingInstructionType with mode ValidationMode resolves to none


    ----------------------------------------------------
    comment with mode ValidationMode resolves to none

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23381</commentid>
    <comment_count>5</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2009-02-02 11:06:19 +0000</bug_when>
    <thetext>That looks good to me, so I&apos;m happy to close if no one else has a problem with it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23388</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-02 18:58:23 +0000</bug_when>
    <thetext>Well, it would need to be approved by the WG first.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23433</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-04 06:44:32 +0000</bug_when>
    <thetext>At their joint meeting this morning, the XQuery and XSL WGs approved the proposal in comment #4. Consequently I&apos;m marking this issue resolved-FIXED. Since you have already expressed your approval of the proposal, I will also take the liberty of closing the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23761</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-16 07:42:50 +0000</bug_when>
    <thetext>This issue has been entered as FS erratum E058, and the proposed fixes have
been committed to the source files for the next edition of the FS document.
(Mind you, I made some editorial changes to the new judgment forms, to
reduce confusion with the judgment defined in 8.6.1.)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>