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

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


jmdyck@ibiblio.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Comment #4 from jmdyck@ibiblio.org  2008-02-15 09:43 -------
Ah, I see. So, for example, consider:
    fn:min( if (fn:true()) then (1,2) else (3e0, 4e0) )
The argument's static type is
    (xs:integer,xs:integer) | (xs:double,xs:double)
whose prime type is
    xs:integer | xs:double
and the least type that both can promote to is xs:double, so the inferred
static type for the whole is xs:double. However, we know that the expression's
value is the integer 1, which does not match the type xs:double, so type
soundness is broken.

One approach to fixing this might be the following: After computing the prime
type and pushing it through convert_untypedAtomic, consider all possible
combinations of its item types. For each such combination, find the least
common type (by subtype substitution and numeric promotion). Then take the
union of all the least types and 'multiply' it by aggregate_quantifier(...).

So, for the example above, there are three combinations:
    xs:integer
    xs:double
    xs:integer xs:double
The least common types are
    xs:integer
    xs:double
    xs:double
respectively. And the union of those three types (i.e., xs:integer | xs:double)
is the inferred static type for the call.

Received on Friday, 15 February 2008 09:43:41 UTC