[Bug 4272] [FS] Type checking fn:data

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





------- Comment #10 from jmdyck@ibiblio.org  2007-04-28 00:54 -------
(personal response)

Re Comment #0:
If the Static Typing Feature is in effect, and static analysis of a call to
fn:data() finds that the static type of the argument prevents the inference of
a static type for the call, then I believe a type error [err:XPTY0004] is
raised. [XQuery 2.2.3.1 plus FS 7.2.6]

Whether or not the Static Typing Feature is in effect, if static analysis can
determine that, if evaluated, the fn:data() call would necessarily be applied
to a node without a typed value, then the implementation may raise
err:FOTY0012.  [XQuery 2.3.1 plus F+O 2.4]

If the prerequisites for both errors are satisfied, then either or both may be
reported. [XQuery 2.3.1]


Re Comment #2:
Your concern is perhaps valid, but I think the answer to that is helpful error
messages and/or user documentation, not a change to the spec.  Conceivably,
there could be a special error code for
    "the static type satisfies the signature appearing in F+O,
     but not the more precise typing defined by FS 7.2",
but I suspect there's a very low chance of that being adopted via an erratum
against the published Recommendation. It might have more chance in the context
of a future version of the spec.


Re Comment #7:
I agree that the example wouldn't pass static type analysis: in general, a call
to fn:boolean() or fn:data() will not type-check if its argument is declared as
item()*. If, as you suggest, STA *didn't* raise a type error, but evaluation
raised err:FOTY0012, that would violate this fairly fundamental requirement of
XQuery 2.2.3.1:
    If static type checking raises no errors and assigns a static type T to an
    expression, then execution of the expression on valid input data is
    guaranteed either to produce a value of type T or to raise a dynamic error.
Or as XQuery 2.2.3.2 puts it:
    If the Static Typing Feature is in effect, all type errors are detected
    during static analysis...
(Note that err:FOTY0012 is a type error, not a dynamic error.)

Therefore, I propose that this issue be closed with no change to the
specifications.

Received on Saturday, 28 April 2007 00:54:56 UTC