Bug #4692


MapTest as subtype of Function Type

Added by Michael Kay almost 2 years ago. Updated over 1 year ago.

Start date:
Due date:
% Done:


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



Saxon is accepting map { 1:'A','x':'B' } as an instance of function(xs:anyAtomicType) as xs:string. But this is incorrect: if the map is treated as a function $F, then $F(23) returns () which is not an instance of the declared return type xs:string.

The logic in MapType.relationship() line 324 makes map(K, V) a subtype of F if function(K) as V is a subtype of F, which seems quite wrong; the rule is ยง2.5.6.2 rule 35, which says map(K, V), is a subtype of function(xs:anyAtomicType) as V?.

So both Saxon and the QT3 test appear to be wrong.

Actions #1

Updated by Michael Kay almost 2 years ago

See also bug #2938, which introduced the current rules, and which discusses the problem in the W3C specs.

The proposed rule is now:

A map M matches a TypedFunctionTest function(P) as R if (a) P is a subtype of xs:anyAtomicType, (b) every value in M is an instance of R, and (c) the empty sequence is an instance of R.

Actions #2

Updated by Michael Kay almost 2 years ago

  • Status changed from New to Resolved
  • Applies to branch 10, 9.9, trunk added
  • Fix Committed on Branch 10, 9.9, trunk added

Patch committed (9.9, 10, 11).

Test cases added to QT3 prod-MapTest (MapTest-059 to -066)

Actions #3

Updated by O'Neil Delpratt almost 2 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.2 added

Bug fix applied in the Saxon 10.2 maintenance release.

Actions #4

Updated by O'Neil Delpratt over 1 year ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release added

Bug fix applied on the Saxon maintenance release.

Please register to edit this issue

Also available in: Atom PDF