Bug #6343
closed![Author: Michael Kay](https://www.gravatar.com/avatar/db6526d63053f09b62e52c2da8b2230a?rating=PG&size=50&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
![Assignee: Michael Kay](https://www.gravatar.com/avatar/db6526d63053f09b62e52c2da8b2230a?rating=PG&size=22&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
Function 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 3 months 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.)
Updated by O'Neil Delpratt 14 days ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 12.5 added
Bug fix applied in the Saxon 12.5 Maintenance release.
Updated by Debbie Lockett 14 days ago
- Status changed from Closed to Resolved
- % Done changed from 100 to 0
- Fixed in Maintenance Release deleted (
12.5)
The fix has only been made on the trunk branch, for the next major release. It has not been changed for Saxon 12.5.
Please register to edit this issue