Bug #4203


XQuery: Maps and type declarations

Added by Christian Grün over 3 years ago. Updated almost 3 years ago.

XPath conformance
Start date:
Due date:
% Done:


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


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

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)
Actions #1

Updated by Michael Kay over 3 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().

Actions #2

Updated by Michael Kay almost 3 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 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 (and indeed in

Please register to edit this issue

Also available in: Atom PDF