This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3279 - XQPST0081 is incorrectly used for undeclared variables
Summary: XQPST0081 is incorrectly used for undeclared variables
Status: CLOSED FIXED
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: 0.9.0
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Jinghao Liu
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-12 12:57 UTC by Marc Van Cappellen
Modified: 2006-07-06 13:05 UTC (History)
0 users

See Also:


Attachments

Description Marc Van Cappellen 2006-05-12 12:57:16 UTC
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 <file name="{$folder/File/FileName}"/>
XQTS 0.9.0 expects XPST0081, where we believe it should still eb XPST0008.
In paragraph "3.1.2 Variable References" 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'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
Comment 1 Marc Van Cappellen 2006-05-12 13:16:27 UTC
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.
Comment 2 Carmelo Montanez 2006-05-17 18:29:09 UTC
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
Comment 3 Marc Van Cappellen 2006-05-17 18:56:50 UTC
Let'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
Comment 4 Marc Van Cappellen 2006-05-17 20:17:40 UTC
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
Comment 5 Carmelo Montanez 2006-05-18 17:37:29 UTC
Marc:

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

Thanks,
Carmelo
Comment 6 Marc Van Cappellen 2006-06-17 21:54:51 UTC
In XQTS 0.9.4, one query does't seem tio be fixed.

Expressions\FLWORExpr\LetExpr\LetExpr021.xq
Comment 7 Carmelo Montanez 2006-06-20 13:19:55 UTC
Marc:

All tests should now have the correct expected code.

Thanks,
Carmelo

Comment 8 Tom Brosens 2006-07-06 13:05:04 UTC
Yes, all are OK now! Closing.

Thanks,
Tom.