Bug #2938
Updated by Michael Kay about 8 years ago
An instance of test in which the LHS is a map, and the RHS is a specific function type, is returning false when it should return true. For example test case map-merge-003-hof: the following assertion should be true @map{"a", 1 to 5} to5} instance of function(xs:anyURI) as xs:integer*@ The rules here are rather technical. They Any map is an instance of function(X) as Y for any atomic type X, because when M is a map and A is an atomic value, M(A) is a legitimate function call (if the map does not contain any entry matching A, the call returns (), it does not fail). The rules are covered by the itemType-subType() judgement, specifically: Rule 35 [A is a subtype of B if] Ai is map(K, V), and Bi is function(xs:anyAtomicType) as V?. Rule 26 [A is a subtype of B if] Ai is function(a1) as Ar, Bi is function(b1) as Br, Br is a subtype of Ar, and b1 is a subtype of a1. We have a map here whose values are all sequences of integers, therefore it is an instance of map(X, xs:integer*) V) for some X, therefore it is an instance of function(xs:anyAtomicType) as xs:integer*, therefore it is an instance of function(xs:anyURI) as xs:integer*. Essentially a map is an instance of function(X) as Y if (a) X is a subtype of xs:anyAtomicType, and (b) all the values in the map are instances of Y.