Bug #4203
closedXQuery: Maps and type declarations
0%
Description
Both of the following expressions return A
and B
(as expected):
let $s as map(xs:anyAtomicType, xs:string) := map { 1:'A','x':'B' }
return $s?*
let $s as function(xs:string) as xs:string := map { 1:'A','x':'B' }
return $s?*
I understand why the xs:string
parameter type is valid in the second expression (the map can be called with all kinds of atomic types as arguments).
The following expression raise an error, though (with Saxon-EE 9.9.1.2J):
let $s as function(xs:anyAtomicType) as xs:string := map { 1:'A','x':'B' }
return $s?*
XPTY0004: The required item type of the value of variable $s is
(function(xs:anyAtomicType) as xs:string)
Updated by Michael Kay almost 5 years ago
Yes, there's definitely a bug here.
The error is reported statically. We're computing the relationship between
(a) (function(xs:anyAtomicType) as xs:string)
(b) map(xs:anyAtomicType, xs:string)
and to do this we compute the inverse relationship. The logic for getting the relationship between a map type A and a function type B treats the map type in terms of the equivalent function signature and compares the two function signatures, but this is clearly incorrect because it can conclude that A subsumes B, whereas it's obvious that a function is not substitutable for a map.
Relevant logic is in MapType.relationship()
and SpecificFunctionType.relationship()
.
Updated by Michael Kay over 4 years ago
- Category set to XPath conformance
- Status changed from New to Closed
- Assignee set to Michael Kay
- Priority changed from Low to Normal
- Applies to branch 9.9, trunk added
- Fix Committed on Branch 9.9, trunk added
- Fixed in Maintenance Release 9.9.1.4 added
I have added a QT3 test case MapTest-058.
It seems that a bug fix was committed on 3 May 2019, but the bug entry was not updated to reflect this. The bug fix is present in 9.9.1.5 (and indeed in 9.9.1.4)
Please register to edit this issue