Skip to content

Attempt to properly implement ? and + signature semantics#777

Open
mikhail-barg wants to merge 1 commit intojsonata-js:masterfrom
mikhail-barg:master
Open

Attempt to properly implement ? and + signature semantics#777
mikhail-barg wants to merge 1 commit intojsonata-js:masterfrom
mikhail-barg:master

Conversation

@mikhail-barg
Copy link
Copy Markdown
Contributor

@mikhail-barg mikhail-barg commented Mar 30, 2026

This PR attempts to address #776

I'm referring to the docs on + and ? and my interpretation of these lines is as follows:

  • if an argument with ? does not match anything, it gets no value => gets undefined;
  • if an argument with + matches multiple values, it gets an arry of these values as a value (because there's no other way to pass multiple values into a single argument), so:
    • n+ matching 1.0 would result in a literal 1.0
    • n+ matching 1.0, 2.0, 3.0 woul result in array [1.0, 2.0, 3.0]

As you may see, I've only changed recently added 035 and 040 tests to match the semantics above, so I believe this change is not a major breaking change. It's more like covering previously vague topic. I've also added a number of tests to display the behaviour more explicitly.

@andrew-coleman what do you think?

@Turings98apprentice
Copy link
Copy Markdown
Contributor

While I would agree that the docs do not seem to match the current behavior, I do believe this is a breaking change, because it changes how function arguments are set. JSONata scripts written before this change would have no guarantee of working the same after this change.

I think this is a step in the right direction for function signatures, but I also think we need to examine this issue a little deeper before making v3.0. For example, there are still other [undocumented (oops)] issues with how function signatures work that we should make an effort to address/correct in the same version jump (imo).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants