[Bug 3971] More XQTS static type errors

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3971





------- Comment #4 from tim@cbcl.co.uk  2007-01-11 16:46 -------
With reference to K-NumericAdd-38, from my reading of the XQuery spec, it is
unclear as to whether a static typing implementation should raise XPTY0004
during type checking when one of the arguments to the operator is the empty
sequence and the other is of a type inappropriate to that operator.

>From XQuery section 3.4:

"Each operand is evaluated by applying the following steps, in order:

1. Atomization is applied to the operand. The result of this operation is
called the atomized operand.
2. If the atomized operand is an empty sequence, the result of the arithmetic
expression is an empty sequence, and the implementation need not evaluate the
other operand or apply the operator. However, an implementation may choose to
evaluate the other operand in order to determine whether it raises an error.
3. If the atomized operand is a sequence of length greater than one, a type
error is raised [err:XPTY0004]."

i.e. By stage (2) we may already have determined that the operator need not be
applied; we know the result must be the empty sequence and there is no need to
ensure that the operands are valid for the operator.

That said, the formal semantics spec doesn't seem to specify that in the static
typing rules (section C.2), although in the dynamic evaluation description it
does specify this behaviour.

The tests K-NumericAdd-40 nodecomparisonerr-1, K-NodeSame-2,
nodecomparisonerr-2, K-NodeBefore-1, K-NodeBefore-2, nodecomparisonerr-3,
K-NodeAfter-1, K-NodeAfter-2 raise similar issues.

Could someone please clarify this issue?

(:*******************************************************:)
(: Test: K-NumericAdd-38                                 :)
(: Written by: Frans Englich                             :)
(: Date: 2006-10-05T18:29:36+02:00                       :)
(: Purpose: Arithmethics involving operands of integer type but with wrong
cardi
nality. :)
(:*******************************************************:)
empty((1, 2) + ())

Received on Thursday, 11 January 2007 16:46:39 UTC