UnaryLookup expression failure

Monday, 30 October 2017 · 2 messages · last reply 1 Nov 2017
GR
Gunther Rademacher30 Oct 2017 20:25 #
While testing some XQuery lookup expressions on BaseX 8.6.7, I got a wrong result for this one: (map{'a':(1,3)},map{'a':(2,4)})!?a[2] It should have returned the second item of the 'a' entry for each of the maps, i.e. 3 4 but it returns just 3 Apparently the predicate is applied as if everything before it was in parentheses, i.e. as if it were ((map{'a':(1,3)},map{'a':(2,4)})!?a)[2] The (simplified) parse tree for the original expression and the XQuery 3.1 grammar however indicates that the predicate is part of the mapping target expression:
     <SimpleMapExpr>
         <ParenthesizedExpr>
            ...
         </ParenthesizedExpr>
         <TOKEN>!</TOKEN>
         <PostfixExpr>
            <UnaryLookup>
               <TOKEN>?</TOKEN>
               <NCName>a</NCName>
            </UnaryLookup>
            <Predicate>
               <TOKEN>[</TOKEN>
               <IntegerLiteral>2</IntegerLiteral>
               <TOKEN>]</TOKEN>
            </Predicate>
         </PostfixExpr>
      </SimpleMapExpr>
Best regards Gunther
CG
Christian Grün1 Nov 2017 10:33 #
Hi Günther, Thanks for the concise bug report. I stumbled across a similar issue just recently [1], so I’m glad to confirm that the latest BaseX 9.0 snapshot returns the correct result [2]. All the best, Christian [1] https://github.com/BaseXdb/basex/commit/ab52f2dde2628bbeac5da22898bf6e28f6826751 [2] http://files.basex.org/releases/latest/
Quoted text · Gunther Rademacher · 44 lines
On Mon, Oct 30, 2017 at 8:25 PM, Gunther Rademacher <grd at gmx.net> wrote: > While testing some XQuery lookup expressions on BaseX 8.6.7, I got a wrong > result for this one: > > (map{'a':(1,3)},map{'a':(2,4)})!?a[2] > > It should have returned the second item of the 'a' entry for each of the maps, > i.e. > > 3 4 > > but it returns just > > 3 > > Apparently the predicate is applied as if everything before it was in > parentheses, i.e. as if it were > > ((map{'a':(1,3)},map{'a':(2,4)})!?a)[2] > > The (simplified) parse tree for the original expression and the XQuery 3.1 > grammar however indicates that the predicate is part of the mapping target > expression: > > <SimpleMapExpr> > <ParenthesizedExpr> > ... > </ParenthesizedExpr> > <TOKEN>!</TOKEN> > <PostfixExpr> > <UnaryLookup> > <TOKEN>?</TOKEN> > <NCName>a</NCName> > </UnaryLookup> > <Predicate> > <TOKEN>[</TOKEN> > <IntegerLiteral>2</IntegerLiteral> > <TOKEN>]</TOKEN> > </Predicate> > </PostfixExpr> > </SimpleMapExpr> > > Best regards > Gunther

⚡Generated with XQuery