Project

Profile

Help

Bug #6343

closed

Function Coercion is not always applied

Added by Michael Kay 5 months ago. Updated 14 days ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2024-02-11
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
11, 12, trunk
Fix Committed on Branch:
trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

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.

Actions #1

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.)

Actions #2

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.

Actions #3

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

Also available in: Atom PDF