Bug #4613
closedMap is not substitutable for Function
100%
Description
The expression filter(1, map{1:true()})
fails "Internal error: filter() function object not instance of XdmFunction".
Updated by Michael Kay over 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.
Updated by Michael Kay over 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).
Updated by Michael Kay over 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.
Updated by Michael Kay over 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
.
Updated by Community Admin almost 4 years ago
- Applies to JS Branch 2 added
- Applies to JS Branch deleted (
2.0)
Updated by Community Admin almost 4 years ago
- Fix Committed on JS Branch 2 added
- Fix Committed on JS Branch deleted (
2.0)
Updated by Debbie Lockett over 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