Skip to content

Commit 8fa1edb

Browse files
fix DualIterMap context value handling
1 parent 37d485f commit 8fa1edb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

basex-core/src/main/java/org/basex/query/expr/DualIterMap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public Value value(final QueryContext qc) throws QueryException {
7171
qf.value = item1;
7272
final Iter iter2 = exprs[1].iter(qc);
7373
for(Item item2; (item2 = qc.next(iter2)) != null;) vb.add(item2);
74+
qf.value = qv;
7475
}
7576
return vb.value(this);
7677
} finally {

basex-core/src/test/java/org/basex/query/ast/RewritingsTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,4 +3398,19 @@ private static String gh1852(final String query) {
33983398
query("let $a := 'x' let $b := if($a) then (<a/>, <b/>) else error() return $b/name()",
33993399
"a\nb");
34003400
}
3401+
3402+
/** DualIterMap context value setting. */
3403+
@Test public void gh2569() {
3404+
check("let $node := <X><A/><B/><C/></X>\n"
3405+
+ "let $pos := $node/A ! position()\n"
3406+
+ "let $nodes := for $c at $i in $node/* where $i gt $pos return $c\n"
3407+
+ "let $flat := $nodes ! (if (*) then * else .)\n"
3408+
+ "return element Y {$flat except $flat[1]}",
3409+
"<Y><C/></Y>", exists(DualIterMap.class));
3410+
check("let $node := <X><A/><B/><C/></X>\n"
3411+
+ "return $node/A ! position()\n"
3412+
+ " -> (for $c at $i in $node/* where $i gt . return $c) ! (* otherwise .)\n"
3413+
+ " -> element Y {. except head(.)}",
3414+
"<Y><C/></Y>", exists(DualIterMap.class));
3415+
}
34013416
}

0 commit comments

Comments
 (0)