Replace use of binary 'or' with logical 'or' #2907
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A recent Chapel PR (chapel-lang/chapel#24155) disallowed the use of expressions like
a < b < c
because of its confusing meaning. Specifically,a < b < c
is not equivalent toa < b && b < c
. Instead, the above expression is equivalent to(a < b) < c
, which is likely not what the author intended. Onmain
, Chapel requires explicit parentheses:(a < b) < c
ora < (b < c)
.This led to us uncovering some bugs that have to do with the use of binary OR
|
instead of the logical or||
. Notably, the the precedence for these operators is as follows:|
>>
>||
. Thus,a < b | c
parses asa < (b | c)
, whereasa < b || c
parses as(a < b) || c
. This is significant in conditionals, such as those affected by the PR:As you can see, this was previously being interpreted as the ternary
.. < .. < ..
expression. This is both likely incorrect logically (I doubt the intention is to comparexiBin
againstyiBin
or'ed with zero) and, on themain
branch of the Chapel compiler, incorrect syntactically.This PR fixes the syntax error caused by this issue, and updates the uses of the bitiwse
|
operator to be uses of the logical||
.