[Bug 4271] [FS} Type checking () op Arg

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

           Summary: [FS} Type checking () op Arg
           Product: XPath / XQuery / XSLT
           Version: Proposed Recommendation
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Formal Semantics
        AssignedTo: simeon@us.ibm.com
        ReportedBy: tim@cbcl.co.uk
         QAContact: public-qt-comments@w3.org


It is unclear whether 

() op Arg

should always return () regardless of whether the operator is defined for the
type of Arg.

For an example, see XQTS test K-NumericAdd-38:

empty((1, 2) + ())

The expected result is the empty sequence.  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 ...

This implies that, by step 2, we can determine that the result of the
expression is the empty sequence.  We could therefore have written an
expression such as:

() + "a string"

and determined that the result is the empty sequence, even though fs:plus is
not defined on string arguments.

If this is the correct interpretation, then the typing rules in "C.2 Mapping of
Overloaded Internal Functions" should be extended to cover this case. 
Specifically, they do not cover the case of binary operators when one of the
arguments is the empty sequence and the other has a type not ordinarily
supported by that operator.

Received on Tuesday, 23 January 2007 08:44:53 UTC