Project

Profile

Help

Bug #4203

XQuery: Maps and type declarations

Added by Christian GrĂ¼n 5 months ago. Updated 11 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2019-04-24
Due date:
% Done:

0%

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

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)

History

#1 Updated by Michael Kay 5 months 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().

#2 Updated by Michael Kay 11 days 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

Also available in: Atom PDF