[Bug 5459] [FS] Static type analysis for the fn:abs, fn:ceiling, fn:floor, fn:round, and fn:round-half-to-even functions

------- Comment #8 from jmdyck@ibiblio.org  2008-04-01 03:56 -------
(In reply to comment #7)
>
> Consider the following query:
> abs(
>   remove( (xs:integer("-1"), xs:float("-2.0")), 2 )
> ) instance of xs:float
> 
> ...
> Along with the rules given in Formal Semantics 4.1.5 this says that during
> static analysis, only a type is assigned to the function call (in this case
> the type assigned is xs:float through the rules in 7.2.3),

Agreed.

> and that the function itself is chosen when the call is evaluated
> and in this case the version operating on xs:floats is selected,
> and so the argument is cast to a float

I'm not sure what leads you to that conclusion. The only suggestion I could
find that there even *are* multiple "versions" of fn:abs is in F+O section 1.4,
where it says that a signature involving 'numeric' represents four signatures.
But the XQuery and FS specs are fairly clear that fn:abs has only one signature
and one implementation. As far as I can tell, they agree that the argument to
fn:abs is not cast to anything, and so the result is also an xs:integer.

> I suggest that the static type of the function (in the first case) should have
> been inferred as xs:integer | xs:float.

Yes, I agree, that needs to be fixed.

> This however leaves the selection of the function used ambiguous,

There I disagree. The static type inferred for a function call does not
influence its dynamic evaluation.

Received on Friday, 4 April 2008 09:59:49 UTC