Bug #4613
closed
Map is not substitutable for Function
Fix Committed on JS Branch:
2
Description
The expression filter(1, map{1:true()})
fails "Internal error: filter() function object not instance of XdmFunction".
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.
- 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).
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.
- 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
.
- Applies to JS Branch 2 added
- Applies to JS Branch deleted (
2.0)
- Fix Committed on JS Branch 2 added
- Fix Committed on JS Branch deleted (
2.0)
- 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