Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion basex-core/src/main/java/org/basex/query/expr/AFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public final Expr inline(final InlineContext ic) throws QueryException {
if(changed) root = inlined;

// do not inline context reference in predicates
changed |= ic.var != null && ic.cc.ok(root, true, () -> ic.inline(exprs));
final Expr ctx = this instanceof StructFilter ? null : root;
changed |= ic.var != null && ic.cc.ok(ctx, true, () -> ic.inline(exprs));

return changed ? optimize(ic.cc) : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.basex.query.util.list.*;
import org.basex.query.value.*;
import org.basex.query.value.item.*;
import org.basex.query.value.map.*;
import org.basex.query.value.type.*;
import org.basex.query.var.*;
import org.basex.util.*;
Expand Down Expand Up @@ -92,7 +91,8 @@ public Expr optimize(final CompileContext cc) throws QueryException {
final int arity = ft.argTypes.length;
if(nargs != arity) throw arityError(func, nargs, arity, false, info);
for(int a = 0; a < arity; ++a) {
final SeqType st = func instanceof XQMap ? Types.ANY_ATOMIC_TYPE_O : ft.argTypes[a];
final SeqType st = func.seqType().type instanceof MapType
? Types.ANY_ATOMIC_TYPE_O : ft.argTypes[a];
exprs[a] = new TypeCheck(info, exprs[a], st).compile(cc);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,12 @@ declare record local:rec(i as xs:integer, inc as fn(local:rec) as local:rec := f
};
local:self(identity#1)""", INVCONVERT_X_X_X);
}

/** Map lookup causing double to integer comparison; StructFilter context setting. */
@Test public void gh2546() {
query("let $m := { 1: 0 } return $m({ \"x\": 1e0 }?x)", "0");
query("let $m := { 1: 0 } return $m(1e0)", "0");
query("let $filter := fn($k, $v) { $k = $v }\n"
+ "return { 0: 0 }?[$filter(?key, ?value)]", "{0:0}");
}
}