-
Notifications
You must be signed in to change notification settings - Fork 15
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] Or and And words don't make their jobs #23
Comments
Trying to set a single variable to multiple values shouldnt error, not just select one of them, no? |
It should select one of them in fact (see the getValues method of the expression) |
This issue is due to the |
Why not give priority to single value expressions if one is asked? For example:
Then if the user wants to set a list to a single value using the condition operators, it can just use the workaround of setting it to a single temporary variable first and then using that variable to set the list variable. Does that make sense? |
That could work fine for variables, but for other changeable expressions less so. Imagine a singular expression that allows being changed using multiple values : which one should be picked in such a case? |
Just looked at the Either way, I just looked at some of the code and found some redundancy that may have to do with this issue: @Override
public Class<?>[] acceptsChange(ChangeMode mode) {
if (!list && mode == ChangeMode.SET)
return new Class[]{Object[].class};
return new Class[]{Object[].class};
} (Variable.java) |
Well, no, since that singular/plural distinction has to be made much earlier at parse time (in fact it has to be made at matching time), and acceptsChange isn't called until much later in the process. |
I guess what I found is related to this issue: When creating the pull request #60, the Expected: set {_upper::*} to all upper case chars in "Hello World" and "Hello Parser"
print "Upper: %{_upper::*}% # Upper: "H", "W", "H" and "P" Got: set {_upper::*} to all upper case chars in "Hello World" and "Hello Parser"
print "Upper: %{_upper::*}% # Upper: "H", "W" and "Hello Parser" |
That's because list literals come before expressions in the parsing order. Use parentheses to specify the correct interpretation. |
Maybe force-parsing (as I will call it for now) for ExprBooleanOperators could fix the issue? |
* fix: boolean operator fix (#23) * suggestion Co-authored-by: Giovanni <42092549+Matocolotoe@users.noreply.github.com> * improve: small code improvement * request: add requests * request: add request * improve: small parsing optimization Co-authored-by: CHarcoalToast <CharcoalToast@users.noreply.github.com> Co-authored-by: Giovanni <42092549+Matocolotoe@users.noreply.github.com>
Description
Recently I saw when working on #22 that the
and
andor
operators didn't work correctly sometimes.Expected
Code:
It's good to note using operators as
&&
instead ofand
it works perfectly. No errors, simply wrong results.The text was updated successfully, but these errors were encountered: