This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 1431 - [FO/FS] Constrain $zero to be compatible if static typing is available
Summary: [FO/FS] Constrain $zero to be compatible if static typing is available
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Formal Semantics 1.0 (show other bugs)
Version: Last Call drafts
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Jerome Simeon
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-13 22:54 UTC by Michael Rys
Modified: 2005-09-06 12:57 UTC (History)
0 users

See Also:


Attachments

Description Michael Rys 2005-05-13 22:54:12 UTC
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.
Comment 1 Jerome Simeon 2005-07-19 20:57:23 UTC
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
Comment 2 Andrew Eisenberg 2005-07-19 23:34:45 UTC
The WGs have accepted Jderome's solution to this issue.