<?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>3279</bug_id>
          
          <creation_ts>2006-05-12 12:57:16 +0000</creation_ts>
          <short_desc>XQPST0081 is incorrectly used for undeclared variables</short_desc>
          <delta_ts>2006-07-06 13:05:04 +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>0.9.0</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="Marc Van Cappellen">marc.van.cappellen</reporter>
          <assigned_to name="Jinghao Liu">jinghaol</assigned_to>
          
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>9761</commentid>
    <comment_count>0</comment_count>
    <who name="Marc Van Cappellen">marc.van.cappellen</who>
    <bug_when>2006-05-12 12:57:16 +0000</bug_when>
    <thetext>Resolving bug 2447 in XQTS seems to have unwanted side-effects. Apparently all references to XPST0008 have been replaced by XPST0081 we believe this is incorrect.

Take for example ForExpr002
  for $folder in $folder/File 
  return &lt;file name=&quot;{$folder/File/FileName}&quot;/&gt;
XQTS 0.9.0 expects XPST0081, where we believe it should still eb XPST0008.
In paragraph &quot;3.1.2 Variable References&quot; of the XQuery spec (including the latest May 10 version) we read:

Every variable binding has a static scope. The scope defines where references to the variable can validly occur. It is a static error [err:XPST0008] to reference a variable that is not in scope. If a variable is bound in the static context for an expression, that variable is in scope for the entire expression.

In addition, note that the query above doesn&apos;t specify any prefix. As such XQST0081 can definitely not apply as it reads:

err:XPST0081: It is a static error if a QName used in a query contains a namespace prefix that cannot be expanded into a namespace URI by using the statically known namespaces.

Here is the complete list of tests for which the switchfrom XPST0008 to XPST0081 is incorrect:

ForExpr002
ForExpr009
LetExpr021
ReturnExpr014
WhereExpr002
WhereExpr018
vardeclwithtype-15
statictyping-21

Thanks,
Marc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9763</commentid>
    <comment_count>1</comment_count>
    <who name="Marc Van Cappellen">marc.van.cappellen</who>
    <bug_when>2006-05-12 13:16:27 +0000</bug_when>
    <thetext>As additional information, note that this was already reported and fixed with bug 3267. However, the list of tests in that bug seems to be incomplete.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9831</commentid>
    <comment_count>2</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-05-17 18:29:09 +0000</bug_when>
    <thetext>Marc:

I am reassigning the bug to Microsoft as most of the test are theirs.
I did looked at my tests,vardeclwithtype-15 and statictyping-21.  I do not
see how this bug pertains to those two tests.  Please comment.

Thanks,
Carmelo
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9834</commentid>
    <comment_count>3</comment_count>
    <who name="Marc Van Cappellen">marc.van.cappellen</who>
    <bug_when>2006-05-17 18:56:50 +0000</bug_when>
    <thetext>Let&apos;s take a closer look at vardeclwithtype-15

declare variable $var as xs:integer := $e +1;
declare variable $e as xs:integer := 10;
$var

$e is used before being declared.

In http://www.w3.org/TR/xquery/#id-variables we read:
It is a static error [err:XPST0008] to reference a variable that is not in scope.

Does this helps?
Marc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9838</commentid>
    <comment_count>4</comment_count>
    <who name="Marc Van Cappellen">marc.van.cappellen</who>
    <bug_when>2006-05-17 20:17:40 +0000</bug_when>
    <thetext>to complete comment #3, let me add a reference to http://www.w3.org/TR/xquery/#id-variable-declarations

It says:
The static context for an initializing expression includes all functions that are declared or imported anywhere in the Prolog, but it includes only those variables and namespaces that are declared or imported earlier in the Prolog than the variable that is being initialized.

I hope this helps,
Marc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9859</commentid>
    <comment_count>5</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-05-18 17:37:29 +0000</bug_when>
    <thetext>Marc:

Correct.  I updated the catalog file for all the tests (NIST&apos;s and Microsoft&apos;s) to expect code XPST0008.  Please close the bug if in agreement.

Thanks,
Carmelo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10085</commentid>
    <comment_count>6</comment_count>
    <who name="Marc Van Cappellen">marc.van.cappellen</who>
    <bug_when>2006-06-17 21:54:51 +0000</bug_when>
    <thetext>In XQTS 0.9.4, one query does&apos;t seem tio be fixed.

Expressions\FLWORExpr\LetExpr\LetExpr021.xq</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10157</commentid>
    <comment_count>7</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-06-20 13:19:55 +0000</bug_when>
    <thetext>Marc:

All tests should now have the correct expected code.

Thanks,
Carmelo

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10400</commentid>
    <comment_count>8</comment_count>
    <who name="Tom Brosens">Tom.Brosens</who>
    <bug_when>2006-07-06 13:05:04 +0000</bug_when>
    <thetext>Yes, all are OK now! Closing.

Thanks,
Tom.

</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>