Bugzilla – Bug 17272
Last modified: 2012-10-05 15:59:10 UTC
This test has a couple of problems.
declare variable $var1 := $var1; true()
The expected result is XPST0054, but should be XQST0054. However, this error code is expected to be replaced with XQDY0054 (see Bug 15791).
XQDY0054 being a dynamic error, because this test does not require evaluation of $var1, the test should also expect true().
I propose that we wait for the spec to settle down here as it is in flux.
The current spec contains some contradictory statements. It says (a) that a variable declaration adds a variable "to the static context" (but the static context of what?); it also says (b) "The static context for an initializing expression includes all functions, variables, and namespaces that are declared or imported anywhere in the Prolog, other than the variable being declared" (which means the variable is out of scope, which implies a static error XPST0008, regardless whether the variable is actually used), and (c) If the initializer of a variable V depends on V, a static error is raised [err:XQST0054].
The current spec says:
[Definition: If a variable declaration includes an expression (VarValue or VarDefaultValue), the expression is called an initializing expression. The static context for an initializing expression includes all functions, variables, and namespaces that are declared or imported anywhere in the Prolog, other than the variable being declared.]
Therefore the variable reference $var1 is not in scope. The spec says:
It is a static error [err:XPST0008] to reference a variable that is not in scope.
So we think that XPST0008 is appropriate and that there is not a cycle. To create a cycle there would have to be a link from the variable reference to the declaration and there is no such link because the variable is not in scope.
Error code changed and committed to cvs.