Project

Profile

Help

Bug #4613

closed

Map is not substitutable for Function

Added by Michael Kay almost 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2020-06-25
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

The expression filter(1, map{1:true()}) fails "Internal error: filter() function object not instance of XdmFunction".

Actions #1

Updated by Michael Kay almost 4 years ago

In the code for fn:filter(), there are two problems:

  • Firstly, the code explicitly tests whether the supplied value is an XdmFunction (maps and arrays are not)

  • Secondly, the code invokes the function using the evaluate() method: maps and arrays have no such method.

Other higher-order functions in the core library have similar problems. Some, like for-each, have explicit code to handle this case, others, like for-each-pair, crash in the same way.

Actions #2

Updated by Michael Kay almost 4 years ago

  • Assignee changed from Michael Kay to John Lumley
  • Priority changed from Low to Normal
  • Applies to JS Branch 2.0 added

For this particular test case, I have made it work by (a) changing the logic in fn:filter to test whether the supplied value has an evaluate method, (rather than testing instance of XdmFunction), and (b) adding an evaluate() method to HashTrie.

Similar changes are needed to other higher-order functions (and more QT3 tests are needed).

Actions #3

Updated by Michael Kay almost 4 years ago

I have added a number of QT3 tests to show that maps and arrays are substitutable for functions in calls to fn:filter, fn:for-each, fn:sort, array:filter, array:for-each, array:sort.

Actions #4

Updated by Michael Kay almost 4 years ago

  • Category set to Internals
  • Status changed from New to Resolved
  • Assignee changed from John Lumley to Michael Kay
  • Fix Committed on JS Branch 2.0 added

Fixed. XdmArray and HashTrie now have evaluate methods, and HOFs like array:for-each() check whether the evaluate() method exists, rather than checking whether the value is an XdmFunction.

Actions #5

Updated by Community Admin about 3 years ago

  • Applies to JS Branch 2 added
  • Applies to JS Branch deleted (2.0)
Actions #6

Updated by Community Admin about 3 years ago

  • Fix Committed on JS Branch 2 added
  • Fix Committed on JS Branch deleted (2.0)
Actions #7

Updated by Debbie Lockett about 3 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 2.1

Bug fix applied in the Saxon-JS 2.1 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page