I think I've found another bug (I promise I don't spend my whole day sitting around thinking of ways to break Basex). The test XML is at the bottom of this message. I'm not sure how to classify this bug, but consider the results of the following queries with the initial context set to <bbb>.
Query: count(./preceding-sibling::*)+1 Result: 2 (as expected)
Query: /test/a/ab/*[2] Result: <abb> (as expected)
Query: /test/a/ab/*[count(./preceding-sibling::*)+1] Result: <aba><abb><abc> (was expecting just <abb> as before)
This problem also appears to affect FLOWR expressions when using "for" but not "let"...
Query: let $p := count(./preceding-sibling::*)+1 return /test/a/ab/*[$p] Result: <abb> (as expected)
Query: for $p in 2 return /test/a/ab/*[$p] Result: <abb> (as expected)
Query: for $p in count(./preceding-sibling::*)+1 return /test/a/ab/*[$p] Result: <aba><abb><abc> (was expecting just <abb> as before)
Text XML:
<test> <a> <aa/> <ab> <aba/> <abb/> <abc/> </ab> <ac/> </a> <b> <ba/> <bb> <bba/> <bbb/> <bbc/> </bb> <bc/> </b> </test>