Bug #6343
closedFunction Coercion is not always applied
0%
Description
I have created the following test case FunctionCall-058:
declare function local:f($callback as function(xs:integer) as xs:boolean) as xs:boolean {
$callback(year-from-date(current-date()) div 1900)
};
local:f(function($d as xs:decimal) as xs:boolean { $d lt 0 })
This should fail because the $callback
function requires an xs:integer but the supplied value (the result of the integer division) is an xs:decimal.
What is supposed to happen according to the spec is that the supplied function (which accepts an x:decimal) is coerced to the required type (which does not). The means that the function actually supplied to the $callback parameter is effectively:
function($d1 as xs:integer) as xs:boolean {
function($d2 as xs:decimal) as xs:boolean { $d2 lt 0 } ($d1)
}
which should fail with a type error when called supplying an xs:decimal
.
However, because the value supplied to the $callback
parameter is an instance of the required type, Saxon skips the process of function coercion wrongly believing it to be unnecessary; his has the effect that the type error is not detected.
Updated by Michael Kay 4 days ago
- Status changed from New to Resolved
- Fix Committed on Branch trunk added
We decided to fix this in the next major release; changing the behaviour in a maintenance release is more likely to create problems than to solve them. (We noted that the change stops some long-standing tests in the test suite from working.)
Please register to edit this issue