Strange compilator behavior ?
Monday, 9 October 2017 · 5 messages
JM
jean-marc Mercier9 Oct 2017 17:45 #
Hello BaseX team !
I lost some time to detect an error in my code, and wonder if there is a minor bug into the BaseX compiler. Here is the test
let $elt as element(*)*:= <universe id="yolo"></universe>
for $d in (1 to 1)
return
let $idd := $elt[d]/@id
return ($elt[$d]/@id,$idd)output : id="yolo".
(Hence missing the second "yolo", because the correct query is : let $idd
:= $elt[$d]/@id)However I can't figure out why the BaseX compiler ran this query ? Shouldn't it refused the compilation and point out this error ?
Cheers,
Jean-Marc
CG
Christian Grün9 Oct 2017 17:49 #
Dear Jean-Marc,
Quoted text · jean-marc Mercier · 1 line
> let $idd := $elt[d]/@id
Shouldn’t it be '$d' instead of 'd' ?
let $idd := $elt[$d]/@idCheers,
Christian
Quoted text · jean-marc Mercier · 16 lines
> return ($elt[$d]/@id,$idd) > > output : id="yolo". > > (Hence missing the second "yolo", because the correct query is : let $idd := > $elt[$d]/@id) > > However I can't figure out why the BaseX compiler ran this query ? Shouldn't > it refused the compilation and point out this error ? > > Cheers, > > Jean-Marc > > >
JM
jean-marc Mercier9 Oct 2017 17:54 #
Hello Christian,
Yes. But my question is : why did the BaseX compiler ran the query let $idd
:= $elt[d]/@id ?
Shouldn't it raise a compilation error ?2017-10-09 17:49 GMT+02:00 Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 32 lines
> Dear Jean-Marc, > > > let $idd := $elt[d]/@id > > Shouldn’t it be '$d' instead of 'd' ? > > let $idd := $elt[$d]/@id > > Cheers, > Christian > > > > > return ($elt[$d]/@id,$idd) > > > > output : id="yolo". > > > > (Hence missing the second "yolo", because the correct query is : let > $idd := > > $elt[$d]/@id) > > > > However I can't figure out why the BaseX compiler ran this query ? > Shouldn't > > it refused the compilation and point out this error ? > > > > Cheers, > > > > Jean-Marc > > > > > > >
CG
Christian Grün9 Oct 2017 18:00 #
Quoted text · jean-marc Mercier · 2 lines
> Yes. But my question is : why did the BaseX compiler ran the query let $idd > := $elt[d]/@id ?
The query is valid, because $elt could have an element named d. For
example, the following query returns the value of $elt:
let $elt := <u><d/></u>
return $elt[d]Does this help?
Christian
Quoted text · jean-marc Mercier · 39 lines
> Shouldn't it raise a compilation error ? > > > > 2017-10-09 17:49 GMT+02:00 Christian Grün <christian.gruen at gmail.com>: >> >> Dear Jean-Marc, >> >> > let $idd := $elt[d]/@id >> >> Shouldn’t it be '$d' instead of 'd' ? >> >> let $idd := $elt[$d]/@id >> >> Cheers, >> Christian >> >> >> >> > return ($elt[$d]/@id,$idd) >> > >> > output : id="yolo". >> > >> > (Hence missing the second "yolo", because the correct query is : let >> > $idd := >> > $elt[$d]/@id) >> > >> > However I can't figure out why the BaseX compiler ran this query ? >> > Shouldn't >> > it refused the compilation and point out this error ? >> > >> > Cheers, >> > >> > Jean-Marc >> > >> > >> > > >
JM
jean-marc Mercier9 Oct 2017 18:06 #
Christian,
Yes absolutely. Thx for your answer.
Cheers,
Jean-Marc
2017-10-09 18:00 GMT+02:00 Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 55 lines
> > Yes. But my question is : why did the BaseX compiler ran the query let > $idd > > := $elt[d]/@id ? > > The query is valid, because $elt could have an element named d. For > example, the following query returns the value of $elt: > > let $elt := <u><d/></u> > return $elt[d] > > Does this help? > Christian > > > > > Shouldn't it raise a compilation error ? > > > > > > > > 2017-10-09 17:49 GMT+02:00 Christian Grün <christian.gruen at gmail.com>: > >> > >> Dear Jean-Marc, > >> > >> > let $idd := $elt[d]/@id > >> > >> Shouldn’t it be '$d' instead of 'd' ? > >> > >> let $idd := $elt[$d]/@id > >> > >> Cheers, > >> Christian > >> > >> > >> > >> > return ($elt[$d]/@id,$idd) > >> > > >> > output : id="yolo". > >> > > >> > (Hence missing the second "yolo", because the correct query is : let > >> > $idd := > >> > $elt[$d]/@id) > >> > > >> > However I can't figure out why the BaseX compiler ran this query ? > >> > Shouldn't > >> > it refused the compilation and point out this error ? > >> > > >> > Cheers, > >> > > >> > Jean-Marc > >> > > >> > > >> > > > > > >
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery