json-formula icon indicating copy to clipboard operation
json-formula copied to clipboard

Calling registered functions with 0 arguments.

Open Eswcvlad opened this issue 1 year ago • 1 comments

Currently in the spec:

The registered function may take one parameter.

It is pretty clear, that it would be implemented by just evaluating the expression with the argument as the contextual input JSON. But it is not quite clear, what that input should be in the json-formula context, when 0 arguments are provided.

In the current implementation, it looks like it just has js "undefined" as the input, which can leak in the results. For example, an expression like register("_identity", &@) || _identity() results in undefined.

Maybe it would be better to specify the default value for the argument in such cases, like null or {}?

Eswcvlad avatar Jul 04 '24 15:07 Eswcvlad

Good question. I think null makes most sense.

JohnBrinkman avatar Jul 09 '24 14:07 JohnBrinkman