Menu

#153 (int div int) gives ClassCastException

v7.6.5
closed
5
2012-10-08
2003-08-14
Michael Kay
No

The static type of ($x div 2) where $x is an integer,
is being wrongly inferred as xs:integer rather than
xs:decimal. This can lead to a ClassCastException if
the result is used in a context where an integer is
expected, for example

1 to xs:integer($x div 2)

Occurs in 7.6.5 and possibly earlier releases.

Source code fixed (extra logic added to getItemType()
in ArithmeticExpression.

Test case added: bug97

Discussion