-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: $x.$number()
incorrectly returns no value
#155
Comments
Hi! Was checking out the public repos and stumbled upon this so gave it a deep dive to start getting up to speed. Disclaimer: new to jsonata / rust so might be off :P Per the Jsonata docs , if In the JS implementation, the implicit context logic is built around the signature itself. There is a signature utility function called validate that actually (sneakily) also does the substitution of the optional missing arguments with the context value. This is then used by validateArguments which is used by applyInner which is the place where functions are actually applied. Currently However, I think it’s fair to argue that at least the built-in functions should match the API as defined by the JSONata public docs, i.e. $number() explicitly mentions that
This doesn’t really have to do with the implementation details of signatures and seems straightforward to implement (in fact, already working for $string() and it can be confusing that it works for string, but not number). Implementation can look like this, (would just need to follow same pattern for the rest of the built-in functions that have context parms per JS impl) |
The
.
syntax introduces a "context" variable named$
. Some built-in functions ($string
,$number
,$abs
, etc) are meant to use the value of$
as the first parameter if no explicit arguments are provided. This is probably a discrepancy with our other functions as well.Note that this behavior is (as far as I can tell) specific to each function. That is, it's not the case that every function invoked in this way gets the context parameter injected. Eg:
The text was updated successfully, but these errors were encountered: