[Bug 27059] [xp3.1] Function coercion, maps and arrays

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27059

--- Comment #4 from John Snelson <john.snelson@marklogic.com> ---
An example of function coercion against a map item to include in the spec:

let $m := map {
  "Monday" : true(),
  "Wednesday" : true(),
  "Friday" : true(),
  "Saturday" : false(),
  "Sunday" : false()
}
let $days := ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
"Saturday", "Sunday")
return fn:filter($days,$m)


The map $m has a function signature of function(xs:anyAtomicType) as item()*.
When the fn:filter() function is called, the following occurs to the fun\
ction:

1. The map $m is treated as function ($f) equivalent to map:get($m,?).
2. The function conversion rules result in applying function coercion to $f,
wrapping $f in a new function ($p) with the signature function(item()) as\
 xs:boolean.
3. $p is matched against the SequenceType of function(item()) as xs:boolean,
and succeeds.
4. When $p is invoked by fn:filter(), function conversion and SequenceType
matching rules are applied to the argument, resulting in an item() value ($\
a) or a type error.
5. $f is invoked with $a, which returns an xs:boolean or the empty sequence.
6. $p applies function conversion rules and SequenceType matching to the result
sequence from $f. When the result is an xs:boolean the SequenceType ma\
tching succeeds. When it is an empty sequence (such as when $m does not contain
a key for "Tuesday"), SequenceType matching results in a type error.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Thursday, 16 July 2015 20:32:33 UTC