Project

Profile

Help

Bug #6271

closed

In 4.0, reduced-arity coercion fails when target function has optional parameters

Added by Michael Kay 6 months ago. Updated 6 months ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
Features new in 4.0
Sprint/Milestone:
-
Start date:
2023-12-01
Due date:
% Done:

0%

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

Description

See QT3 test case FunctionCall-417

         declare function local:f($x as xs:string, $y as xs:string, $z as xs:string := '1900-01-01') as xs:string {
           concat($x, '-', $y, ' on ', $z)
         };
         declare function local:g($x as xs:string, $z as function(xs:string, xs:string, xs:integer) as xs:string) {
           $z($x, $x, 22)
         };  
         local:g("ABC", local:f#2)

The function local:f#2 should be equivalent to fn($x, $y){concat($x, '-', $y, ' on ', '1900-01-01'); the call on $z should accept this arity-2 function by virtue of reduced-arity coercion, and the third argument (22) should be ignored. In fact we get a run-time type error because local:f expects a string, not an integer, as its third argument.

The effect is more noticeable when we supply something like deep-equal#2 as an argument to for-each-pair. Now that for-each-pair accepts an arity-3 callback, with the third argument being an integer position, we get a spurious failure because deep-equal has an arity-3 variant that expects a string as the third argument. (But this manifestation is not present in 12.4, because that does not yet implement the arity-3 callback on for-each-pair).

Please register to edit this issue

Also available in: Atom PDF