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

OR operator return always true #2

Open
drimondi1 opened this issue Mar 21, 2022 · 3 comments
Open

OR operator return always true #2

drimondi1 opened this issue Mar 21, 2022 · 3 comments

Comments

@drimondi1
Copy link

Hi @matheval
really thanks for you library works very well.
I'm facing an issue with "OR" operator that returns always "true".
please find below an online example
https://dotnetfiddle.net/P9zFsG

can you help me ?
Thanks in advance
Davide

@nielll
Copy link

nielll commented May 12, 2022

Hi @drimondi1 and @matheval

Until it is fixed you can also generate OR with NOT and AND. This workaround works.

// according to De Morgan's Law
A OR B = NOT ( NOT A AND NOT B ) 

@matheval
Copy link
Owner

@drimondi1 @nielll
I may have free time on June or July and i will fix it.
thank for using this.

@tevarg
Copy link

tevarg commented Jul 28, 2022

Just change the following line "if ((item is Boolean) || (Boolean)item)" to "if ((item is Boolean) && (Boolean)item)"
in the following block:

    private Boolean LogicalOr(Dictionary<string, Object> args)
    {
        foreach (Object item in args.Values)
        {
            if ((item is Boolean) && (Boolean)item)
            {
                return true;
            }
        }
        return false;
    }

butulia added a commit to butulia/expression-evaluator-c-sharp that referenced this issue Sep 5, 2022
matheval added a commit that referenced this issue Sep 6, 2022
Fix Issues #2 and #3 from Butulia
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

4 participants