Skip to content

Inline and reports error on operator instead of failing function #765

@benny779

Description

@benny779

Description

When using the logical and operator inline, JSONata reports an incorrect error message pointing to and, instead of the actual failing function call.
However, when the same expression is wrapped inside a user-defined function, the error is reported correctly.

This makes debugging more difficult, as the reported error source differs depending on context.


Reproduction

Case 1 – Inline expression (incorrect error)

(
  1=1 and $contains([''], '')
)

Actual error

Argument 1 of function "and" does not match function signature

Case 2 – Expression inside a function (correct error)

(
  $fn = function($a, $b) { $a and $b };
  $fn(1=1, $contains([''], ''))
)

Actual error

Argument 1 of function "contains" does not match function signature

This is the correct and expected behavior.


Expected Behavior

Error reporting should be consistent regardless of whether the and operator is used inline or inside a user-defined function.
Specifically, errors should surface from the actual failing function call, not from the logical operator that combines expressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions