<?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>6677</bug_id>
          
          <creation_ts>2009-03-10 16:14:36 +0000</creation_ts>
          <short_desc>[UPD] bug in static typing checking for  transform expression in XQUF</short_desc>
          <delta_ts>2011-01-08 00:25:04 +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>Update Facility</component>
          <version>Candidate 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="zhen hua liu">zhen.liu</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>jmdyck</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>24130</commentid>
    <comment_count>0</comment_count>
    <who name="zhen hua liu">zhen.liu</who>
    <bug_when>2009-03-10 16:14:36 +0000</bug_when>
    <thetext>In section http://www.w3.org/TR/xquery-update-10/#id-update-typing-transform,
the static typing rules is specified for transform expression in XQUF. However, the rule appears
to be have following issues:

Consider transform expression
copy $var := expr 
modify .... (: some modification on $var ::)
return $var

The semantics of transform expression is that when modify expression is being evaluated, the
$var&apos;s value is not changed, however, when evaluating the return expression, the $var&apos;s value
is changed from the modify expression (that is, snapshot ends and PUL is applied).

Thus when we do static type analysis for modify expression, the $var&apos;s static type shall be
different from the static type of $var when do static type analysis for return expression.

Such type distinction before and after modifcation
 does not appear to be reflected in the XQUF static type analysis rule.
That is the statEnv for all the copied variables needs to be recomputed after analysis of the
modify expression before evaluating the return expression.  Of course, to make static type analysis easier but sound, the type analysis can assign each
variable&apos;s static type as node() after modification is applied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24131</commentid>
    <comment_count>1</comment_count>
    <who name="zhen hua liu">zhen.liu</who>
    <bug_when>2009-03-10 16:15:35 +0000</bug_when>
    <thetext>Andrew further notices the following bug in transform expression static typing rule:
I may be seeing a different problem here. In section 2.4.5 Transform,  rule 1)c)i and ii,  we say:

i) For a copied element node, the type-name property is set to xs:untyped, and the nilled, is-id, and is-idrefs properties are set to false.
ii) For a copied attribute node, the type-name property is set to xs:untypedAtomic and the is-idrefs property is set to false. The is-id property is set to true if the qualified name of the attribute node is xml:id; otherwise it is set to false.


In the modify clause, we could infer a static type for each copy variable of  something like element(*, xs:untyped), attribute(*, xs:untypedAtomic), or just node()? As the copied nodes can be replaced in the modify clause, we should infer only node()* for these variables in the return clause.


                                                -- Andrew
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24287</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-03-17 01:53:24 +0000</bug_when>
    <thetext>Andrew said:
&gt; As the copied nodes can be replaced in the modify clause, we should
&gt; infer only node()* for these variables in the return clause.

I disagree. Although you can replace copied nodes, you can&apos;t replace the
node that a TransformExpr-variable is bound to, because it doesn&apos;t have a
parent. (And even if you *could*, the variable would stay bound to the
node, not the replacement.)

So, to resolve this issue, I propose that in the rule in question,
in the two premises of the form:
    statEnvi = statEnvi-1 + varType(Variablei =&gt; Typei)
we change the &quot;Typei&quot; to
    [[ node() ]]_sequencetype

That is, the static type of each variable (thoughout its scope) is node().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24292</commentid>
    <comment_count>3</comment_count>
    <who name="zhen hua liu">zhen.liu</who>
    <bug_when>2009-03-17 15:32:23 +0000</bug_when>
    <thetext>yes, node() as I stated in the bug description.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24302</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-03-17 23:02:24 +0000</bug_when>
    <thetext>At its meeting this morning, the XQuery WG accepted the proposal
in comment #2, and I have accordingly edited the sources for the
Update spec.  Consequently, I&apos;m marking this issue resolved-FIXED.

If this resolves the issue to your satisfaction, please mark it CLOSED.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>