Project

Profile

Help

Bug #5085

closed

Function annotations not reported for anonymous functions

Added by Mary Holstege about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2021-09-10
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:
Platforms:

Description

In Saxon 10.3 PE saxon:function-annotations() returns nothing on anonymous functions

See attached XQuery for an example

Perhaps by design? My use case is to attach names to anonymous functions for metadata tagging. Unfortunate, not critical.


Files

bug.xqy (1.06 KB) bug.xqy Program to demonstrate issue Mary Holstege, 2021-09-10 17:42
bug.xml (201 Bytes) bug.xml Output Mary Holstege, 2021-09-10 17:42
Actions #1

Updated by Michael Kay about 3 years ago

I added a test case for saxon:function-annotations() applied to an inline function, and it worked.

I will now try your test case.

Actions #2

Updated by Michael Kay about 3 years ago

The problem is that the call on function-annotations() is not being applied to the inline function as written, it is being applied to a rewritten (curried) function of the form

function ($v as xs:double) as xs:double  { 10 * $v }

in which the annotations have been lost.

I guess it's possible to construct a pure XQuery 3.1 test (without Saxon extensions) (using a FunctionTest that tests annotations) that fails for the same reason, so we'll probably have to treat this as a conformance issue. Can't say it's high on my list of priorities though!

Actions #3

Updated by Michael Kay about 3 years ago

No, it's not possible to construct a pure XQuery 3.1 test that fails, because annotation assertions are defined to ignore annotations whose meaning is unknown to the XQuery processor; there are no annotations on inline functions whose meaning is known to Saxon, so all annotations are ignored, and therefore dropping them does no (conformance) harm.

Actions #4

Updated by Michael Kay about 3 years ago

  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch trunk added
  • Fix Committed on Branch 10, trunk added

This turns out to be fairly simple to fix:

(a) the spec says that function coercion should retain type annotations, and it's easy for us to do this simply by adding a method override CoercedFunction.getAnnotations() that gets the annotations of the original function.

(b) the operation of binding the closure variable $scale to its supplied value 10 is implemented by creating a CurriedFunction object, and this already retains the annotations of the original function.

Actions #5

Updated by Michael Kay about 3 years ago

Added qt3extra test case function-annotations-003.

Actions #6

Updated by O'Neil Delpratt about 3 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.6 added

Bug fix applied in the Saxon 10.6 maintenance release

Please register to edit this issue

Also available in: Atom PDF