Dear Mike, Thanks a lot for your response and for extending the test suite accordingly.
I indeed missed "or if the value of E cannot be atomized" at first read, meaning that indeed map{} castable as anything should fail with an error. Kind regards and have a nice evening, Ghislain > On 10 Nov 2020, at 11:54, Michael Kay <m...@saxonica.com> wrote: > > The spec says (very carefully) > > The expression E castable as T returns true if the result of evaluating E can > be successfully cast into the target type T by using a cast expression; > otherwise it returns false. If evaluation of E fails with a dynamic error or > if the value of E cannot be atomized, the castable expression as a whole > fails. > > So if E is map{} then there should definitely be an error because map{} > cannot be atomized. (It's less clear exactly what the error should be, or > whether it can be reported statically). > > If E is array{1,2} then I think the spec says the result should be false: > evaluation of E does not fail, and it can be atomized, and it cannot be cast > to xs:integer. > > I will add some test cases to QT3. > > Michael Kay > Saxonica > >> On 10 Nov 2020, at 10:33, Ghislain Fourny <gfou...@inf.ethz.ch> wrote: >> >> Dear all, >> >> I would like to check something on XQuery 3.1 and in particular the behavior >> of maps/arrays with "castable as" given the way they can and cannot be >> atomized. >> >> Do you agree that >> >> array { 1, 2 } castable as xs:integer >> >> and >> >> map {} castable as xs:integer >> >> should both return false? >> >> >> My first thought was to see what Saxon (I used 9.9.1.7) says (in oXygen) but >> the first query returns true in spite of >> >> array { 1, 2 } cast as xs:integer >> >> throwing an error (as expected) >> >> and the second query returns a null pointer exception (in all likelihood, >> this one is undesired). >> >> Thanks a lot for confirming whether my understanding of the spec is correct! >> >> Thanks and kind regards, >> Ghislain >> >> >> _______________________________________________ >> talk@x-query.com >> http://x-query.com/mailman/listinfo/talk > _______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk