<?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>4248</bug_id>
          
          <creation_ts>2007-01-17 12:23:13 +0000</creation_ts>
          <short_desc>Static typing of K2-DocumentURIFunc-10</short_desc>
          <delta_ts>2007-01-23 17:34:21 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Query Test Suite</product>
          <component>XML Query 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="Tim Mills">tim</reporter>
          <assigned_to name="Frans Englich">frans.englich</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>13656</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2007-01-17 12:23:13 +0000</bug_when>
    <thetext>The argument to fn:root is being typed as a zero-or-more sequence, hence there is a static type check error.

(:*******************************************************:)
(: Test: K2-DocumentURIFunc-10                           :)
(: Written by: Frans Englich                             :)
(: Date: 2007-01-15T15:15:45+01:00                       :)
(: Purpose: Invoke on a tree document node with fn:root(). :)
(:*******************************************************:)
let $i := document
{
&lt;e&gt;
        &lt;a/&gt;
        &lt;a/&gt;
        &lt;a/&gt;
            &lt;b/&gt;
            &lt;b/&gt;
        &lt;a/&gt;
        &lt;a/&gt;
&lt;/e&gt;
}
return empty(document-uri(root($i/a/b[1])))</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13660</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2007-01-17 12:53:43 +0000</bug_when>
    <thetext>K2-StartsWithFunc-1 to 6 and K2-EndsWithFunc-1 to 6 also have the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13716</commentid>
    <comment_count>2</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2007-01-20 12:24:55 +0000</bug_when>
    <thetext>Doesn&apos;t the [1]-predicate ensure a more precise cardinality is inferred? Formal Semantics, 4.3.2 Filter Expressions reads:

&quot;When a predicate with a numeric literal or the last() expression is applied on a primary expression, it is normalized using the fn:subsequence function. This results in a more precise static type for those cases.&quot;

7.2.13 The fn:subsequence function, reads:
&quot;The fn:subsequence function has special static typing rules when its second argument is the numeric literal value 1 or the built-in variable $fs:last. These rules provide better typing for path expressions such as Expr[1] and Expr[fn:last()].&quot;

Therefore, I currently guess that the mentioned tests doesn&apos;t have cardinality-related errors.

However, I think K2-StartsWithFunc-1 to 6 and K2-EndsWithFunc-1 to 6 should fail type check nevertheless because the declared type of the variable, doesn&apos;t match its operand:

declare variable $vA as xs:string := (&quot;B STRING&quot;, current-time(), string(&lt;e&gt;content&lt;/e&gt;))[1];</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13760</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2007-01-22 09:10:16 +0000</bug_when>
    <thetext>$i/a/b[1] is treated as:

$i / a / ( b [1] )

which types as a zero-or-more sequence.

and not:

( $i / a / b )[1]

would would type as a zero-or-one sequence.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13765</commentid>
    <comment_count>4</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2007-01-22 19:49:20 +0000</bug_when>
    <thetext>Yes, I&apos;ll fix K2-DocumentURIFunc-10. Seems that K2-StartsWithFunc-1 to 6 and K2-EndsWithFunc-1 to 6 didn&apos;t have the cardinality error, but the item type mismatch previously fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13784</commentid>
    <comment_count>5</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2007-01-23 16:21:09 +0000</bug_when>
    <thetext>I believe all these issues should be fixed in recent CVS now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13790</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2007-01-23 17:34:21 +0000</bug_when>
    <thetext>K2-DocumentURIFunc-10 is now fixed.  Thanks.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>