-
Notifications
You must be signed in to change notification settings - Fork 220
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
Binding syntax #148
Comments
The middle statement, At the moment, JSONata does allow a variable to be re-bound within a block. E.g. |
Ugh! Yes, I meant Yes, I see that in As for re-assignment, I don't have any issue with that. I'll leave this issue open so it can be addressed in the |
Interesting. I can't imagine why I left this to be caught by the evaluator when it could be picked up by the parser as a syntax error. I'll change that. |
@andrew-coleman Yes, I was wondering about that. I implemented in the evaluator just to mimic 1.5.x, but I'll move it to the parser. Throwing it as a syntax error is preferable because you'll get immediate feedback that the expression itself is invalid. |
See jsonata-js#148 and jsonata-js#150 for details about why.
If you evaluate the following JSONata expression, you get what I would argue is an unintuitive result:
One might expect the answer to be
[1,3]
. Or at least that if you evaluate:you would expect to get
3
.It seems to me that the middle statement in both blocks should either be a syntax error (LHS must be a pure variable expression) or at least a semantic error (binding to non-variable expressions is not allowed). But this doesn't trigger either. Clearly, the middle statement doesn't seem to be having any effect since the answer remains
[1,2]
. To be honest, I haven't dug deeply enough into this to know exactly what effect the middle statement is having, but it seems to me this is irrelevant since the bigger question is how should that statement be evaluated?Personally, I think it should be an error. It seems reasonably easy to detect.
Comments?
The text was updated successfully, but these errors were encountered: