Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Equals/NotEquals operator is now sometimes showing inconsistent behavior #428

Closed
stevenylai opened this issue Jan 12, 2024 · 1 comment · Fixed by #430 or #431
Closed

Equals/NotEquals operator is now sometimes showing inconsistent behavior #428

stevenylai opened this issue Jan 12, 2024 · 1 comment · Fixed by #430 or #431
Labels

Comments

@stevenylai
Copy link
Contributor

stevenylai commented Jan 12, 2024

Related the change from : #421 where we switched from equals to compareTo

Now for the below 2 expressions:

  1. a == ""
  2. "" == a

If evaluated with a = 0, first one will return true because left side is a number, and EvaluationValue.compareTo will attempt to convert the right side to a number value as well, and as long as string is not a valid boolean, it will be converted to 0. Likewise, when left side is string, right side will also be converted to a string hence 2 returns false

Before the change the 2 expressions above are both false which seems to make more sense to me. Perhaps we need to check type for the operator?

@stevenylai stevenylai changed the title Equals/NotEquals operator is now sometimes showing inconsistent behaviro Equals/NotEquals operator is now sometimes showing inconsistent behavior Jan 12, 2024
@uklimaschewski
Copy link
Collaborator

Than you for finding this.
I think the best way is to stay backward compatible and simply make the equals/not equals operator check the types.
If they differ, the operands are not equal.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
2 participants