Skip to content

Composed predicates used as filter arguments do not receive the element input #705

Description

@Seddryck

Summary

A composed predicate works correctly when evaluated directly against a scalar input, but fails when the same predicate is passed as the predicate argument of filter.

This suggests the composed predicate is not receiving the current array element correctly when it is bound/invoked as a function argument.

Minimal reproduction

.\expressif evaluate "filter(less-than(150) |AND greater-than(0))" -i "{30}"

Actual:

{}

Expected:

{30}

A broader case shows the same behavior:

.\expressif evaluate "filter(less-than(150) |AND greater-than(0))" -i "{-10,30,200}"

Actual:

{}

Expected:

{30}

Control cases

Each predicate works independently inside filter:

.\expressif evaluate "filter(less-than(150))" -i "{30,70}"
# {30, 70}

.\expressif evaluate "filter(greater-than(0))" -i "{30,70}"
# {30, 70}

The composed predicate also works correctly when evaluated directly against a scalar:

.\expressif evaluate "less-than(150) |AND greater-than(0)" -i "30"
# true

.\expressif evaluate "less-than(150) |OR greater-than(0)" -i "30"
# true

So the Boolean combinators themselves appear to be correct. The failure is specific to composed predicates bound as arguments to filter.

Expected behavior

filter should evaluate the complete composed predicate against each element of the input array. For example, for input 30, both less-than(150) and greater-than(0) must receive 30 as their input before their Boolean results are combined.

Regression coverage

Add tests covering at least:

  • composed AND predicate as a filter argument;
  • composed OR predicate as a filter argument;
  • multiple input elements where only a subset should pass;
  • direct scalar evaluation of the same composed predicates as a control case.

This behavior is likely related to the predicate-as-Boolean-function refactoring from #663.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions