@@ -3439,7 +3439,7 @@ impl<M: cranelift_module::Module> Codegen<M> {
34393439 self.define_stdlib_fn_2("contains", "knot_text_contains", false);
34403440 self.define_stdlib_fn_2("startsWith", "knot_text_starts_with", false);
34413441 self.define_stdlib_fn_2("endsWith", "knot_text_ends_with", false);
3442− self.define_stdlib_fn_2("elem", "knot_list_elem", false);
3442+ self.define_stdlib_fn_2_rel("elem", "knot_list_elem", false);
34433443 self.define_stdlib_fn_2("diff", "knot_relation_diff", true);
34443444 self.define_stdlib_fn_2("inter", "knot_relation_inter", true);
34453445 self.define_stdlib_sum();
@@ -3454,8 +3454,8 @@ impl<M: cranelift_module::Module> Codegen<M> {
34543454 self.define_stdlib_fn_2_rel("minOn", "knot_relation_min", true);
34553455 self.define_stdlib_fn_2_rel("maxOn", "knot_relation_max", true);
34563456 self.define_stdlib_fn_2_rel("countWhere", "knot_relation_count_where", true);
3457− self.define_stdlib_fn_2("any", "knot_relation_any", true);
3458− self.define_stdlib_fn_2("all", "knot_relation_all", true);
3457+ self.define_stdlib_fn_2_rel("any", "knot_relation_any", true);
3458+ self.define_stdlib_fn_2_rel("all", "knot_relation_all", true);
34593459
34603460 // List ADT builtins (`base.list.*`). Order-preserving sequence ops,
34613461 // runtime-implemented (knot_list_*). Higher-order ones (map/filter/
@@ -16489,11 +16489,15 @@ impl<M: cranelift_module::Module> Codegen<M> {
1648916489 // count : Rel a -> Rel Int — a one-element relation.
1649016490 self.call_rt(builder, "knot_relation_singleton", &[n])
1649116491 }
16492− QueryTerminal::Exists { .. } => self.call_rt(
16493− builder,
16494− "knot_source_query_exists",
16495− &[db, sql_ptr, sql_len, params_rel],
16496− ),
16492+ QueryTerminal::Exists { .. } => {
16493+ let b = self.call_rt(
16494+ builder,
16495+ "knot_source_query_exists",
16496+ &[db, sql_ptr, sql_len, params_rel],
16497+ );
16498+ // any/all/elem : ... -> Rel Bool — a one-element relation.
16499+ self.call_rt(builder, "knot_relation_singleton", &[b])
16500+ }
1649716501 QueryTerminal::Aggregate { result_flag, .. } => {
1649816502 let rt_fn = query.runtime_fn();
1649916503 // SUM and MIN/MAX take an extra I64 flag (is_float / is_text);