Skip to content
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

Issue with suffix functions #4

Open
nighthawk opened this issue Jul 29, 2019 · 2 comments
Open

Issue with suffix functions #4

nighthawk opened this issue Jul 29, 2019 · 2 comments

Comments

@nighthawk
Copy link

I'm incorporating this library into a project where I want to let users create formulas that check against certain fields. This is mostly working, but I've hit a small roadblock when trying to create a x exists suffix operator that basically checks x != nil. This generally works, but fails in certain nesting conditions.

It might have to do something with operator precedence, as changing the order fixes one case but then causes another test case to fail. I'd appreciate some feedback on how to fix this or how to debug this.

The strange thing is that it works fine perfectly if it's a prefix operator (didset X in my example), though I'd prefer the suffix variant.

The full code sample is here, which is a minor modification of the code from the template example in this repo: https://gist.github.com/nighthawk/060475d0ded20788e9269054e152d76d

Any help would be much appreciated!

@tevelee
Copy link
Owner

tevelee commented Aug 1, 2019

Hi @nighthawk,
Thanks for reporting this issue, very useful finding!

I took some time reviewing the related code paths, looks like it's related to an issue with embedding expressions in parentheses. It is not a trivial fix, might take some more time, so I'm letting you know I'm working on a fix.

In the meantime, you are free to use prefix expressions with equivalent functionality - it's just the syntax that differs - which works as expected.

@tevelee
Copy link
Owner

tevelee commented Sep 14, 2019

Status update: I managed to identify the issue. The expression "(toggle == true) and (url exists)" fails because the nested parentheses caused an issue, and the expression matcher only processes the string until the "(toggle == true) and (url" part, and not prioritizing the "url exists" expression.
Note: it works without the parentheses, if the suffix function "exists" has a higher priority than "and"

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

No branches or pull requests

2 participants