<?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>5826</bug_id>
          
          <creation_ts>2008-07-02 12:29:39 +0000</creation_ts>
          <short_desc>parts-q3-2 does not pass static typing</short_desc>
          <delta_ts>2009-02-06 19:14:03 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XQuery Update Facility Test Suite</product>
          <component>XQuery Update Facility Test Suite</component>
          <version>unspecified</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="Tom Brosens">Tom.Brosens</reporter>
          <assigned_to name="Andrew Eisenberg">andrew.eisenberg</assigned_to>
          <cc>andrew.eisenberg</cc>
    
    <cc>jmdyck</cc>
    
    <cc>jonathan.robie</cc>
    
    <cc>marc.van.cappellen</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>21017</commentid>
    <comment_count>0</comment_count>
    <who name="Tom Brosens">Tom.Brosens</who>
    <bug_when>2008-07-02 12:29:39 +0000</bug_when>
    <thetext>Test
----
Test group: UseCases/PartsUpdates
Test query: parts-q3-2.xq
 
Problem
-------
The query does not pass pessimistic static typing because the parameter in the function declaration of local:delete-subtree is typed as &apos;element(part)&apos;. When static typing is supported this results in a XPTY0004 which is currently not accepted as a valid result.

Resolution
----------
There are two possible solutions, or we add XPTY0004 as an acceptable error code to the catalog, or we change the parameter from &apos;element(part)&apos; to &apos;element(part, xs:untyped)&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22473</commentid>
    <comment_count>1</comment_count>
    <who name="Andrew Eisenberg">andrew.eisenberg</who>
    <bug_when>2008-11-19 17:05:36 +0000</bug_when>
    <thetext>I&apos;m seeing this differently than you are. The query in question is:

declare updating function 
             local:delete-subtree($p as element(part))
  {
      for $child in $part-list//part
      where $p/@partid eq $child/@partof
      return (
        local:delete-subtree($child),
        delete node $child
      )
  };

local:delete-subtree($part-list//part[@name=&quot;car&quot;])


I&apos;m guessing that the inferred type of the expression in the initial invocation of delete-subtree, element(part)*, is the problem.  This does not match the declared type of the parameter. I&apos;d suggest fixing this by changing the function definition to:

declare updating function 
             local:delete-subtree($p as element(part)*)
  {
      for $child in $part-list//part
      where $p/@partid = $child/@partof
      return (
        local:delete-subtree($child),
        delete node $child
      )
  };


If you agree, then I&apos;ll make the change and then file this as a bug against the Update Facility Use Cases.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22711</commentid>
    <comment_count>2</comment_count>
    <who name="Andrew Eisenberg">andrew.eisenberg</who>
    <bug_when>2008-12-08 21:35:20 +0000</bug_when>
    <thetext>Please disregard my response in comment #1. I was confused by a mismatch between the query in the test suite:

local:delete-subtree($part-list//part[@name=&quot;car&quot;])

and the query in the Use Cases document:

for $p in doc(&quot;part-list.xml&quot;)//part[@name=&quot;car&quot;]
return 
  local:delete-subtree($p)


I&apos;ve updated the test suite to bring them into sync.

I&apos;ve reported your concern about the type of the $p parameter in Bug #6288.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22776</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-12-16 23:35:16 +0000</bug_when>
    <thetext>The Working Group discussed this issue at its meeting today. We concluded
that after Andrew&apos;s change (reported in comment #2) to the test case query,
it now passes static type analysis.

However, this change deals with cardinality, whereas your proposed solution
deals with type annotations, so it seems unlikely that we have addressed
your original concern. If you think the amended query still fails static
type analysis, please provide more details as to why.

(By the way, &apos;element(part,xs:untyped)&apos; is a strict subtype of
&apos;element(part)&apos;, so it would seem that the only effect (if any) of
changing the parameter type as you suggest would be to *introduce*
a type error, not remove it.)
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22930</commentid>
    <comment_count>4</comment_count>
    <who name="Marc Van Cappellen">marc.van.cappellen</who>
    <bug_when>2009-01-05 22:05:05 +0000</bug_when>
    <thetext>To answer the question in comment #3: &quot;If you think the amended query still fails static type analysis, please provide more details as to why.&quot;

In the end this is similar to bug #2104

- the parameter $p is declared as &quot;element(part)&quot;.
- $p/@partid is typed as attribute(partid, xs:anySimpleType)*
  (similar for $child/@partof)
- As a consequence, $p/@partid eq $child/@partof can statically compare incompatible types and should raise XPTY0004.

As such we see two options
a) adding XPTY0004 as a valid result
b) declaring the parameter as element(part, xs:untyped), will make the eq-comparison pass the static typing rules (This second alternative is obviously only viable assuming that the input document is &quot;untyped&quot; 
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23402</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-02 23:41:51 +0000</bug_when>
    <thetext>Thank you for claifying things in comment #4. I now agree with the problem
you raised initially: an XQuery implementation supporting the Static Typing
Feature (without type extensions) would be required to raise err:XPTY0004
during the static analysis phase, in respect of the expression
    $p/@partid eq $child/@partof
in XQUTS test case parts-q3-2. Sorry for not recognizing that earlier
in the discussion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23403</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-02 23:45:31 +0000</bug_when>
    <thetext>At its meeting on January 27th, the XQuery WG decided to resolve the bug
by leaving the query as is, and adding XPTY0004 as an expected result for
the test case. Consequently, we are marking this issue as resolved-FIXED.
If you agree with this resolution, please mark it CLOSED.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23437</commentid>
    <comment_count>7</comment_count>
    <who name="Tom Brosens">Tom.Brosens</who>
    <bug_when>2009-02-04 09:03:38 +0000</bug_when>
    <thetext>We agree with this resolution. Closing the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23540</commentid>
    <comment_count>8</comment_count>
    <who name="Andrew Eisenberg">andrew.eisenberg</who>
    <bug_when>2009-02-06 19:14:03 +0000</bug_when>
    <thetext>The changes to the test suite have been checked into CVS.
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>