This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
fn:sum($arg as xdt:anyAtomicType*, $zero as xdt:anyAtomicType?) $zero should also be statically restricted to the same set of types for $arg and the type given to $zero should be compatible with the type given to $arg. For example, sum(1+$decimalorempty, xs:duration(...)) should not be allowed. Note that dynamic typing implementation will not be able to provide this since the empty sequence will not know about the other possible value types.
This is certainly possible. Here is the revised static typing rule which achieves Mihael's proposed semantics. statEnv |- Expr1 : Type1 statEnv |- Expr2 : Type2 statEnv |- Type2 <: xdt:anyAtomicType ? Type3 = prime(Type1) Type4 = convert_untypedAtomic(Type3, xs:double) ItemType1, ...,ItemTypen = Type4 Type0 in { xs:integer, xs:decimal, xs:float, xs:double, xdt:yearMonthDuration } statEnv |- ItemTypei can be promoted to Type0 1 <= i <= n statEnv |- Type2 <: Type0 -------------------------------------------------------------------------------- statEnv |- fn:sum(Expr1,Expr2) : Type0 · aggregate_quantifier(quantifier(Type1)) Note that the resulting type does not need a union anymore which is nice. Note also that this will always reject cases where the user writes: fn:sum(//somedates) since this will be normalized to fn:sum(//somedates,0) and 0 is not a date... - Jerome
The WGs have accepted Jderome's solution to this issue.