This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
use-isnan
should only apply to comparison operators
#2317
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.
PR checklist
use-isnan
fails when use NaN in||
operator #2255Overview of change:
The
use-isnan
rule was warning about all binary operators except for the simple assignment operator=
. This was problematic becausex || NaN
is a reasonable thing to do. This change ensures that it only applies to comparison operators. Instead of checking for the assignment exception, the rule now checks against a complete list of comparison operators.Is there anything you'd like reviewers to focus on?
Most binary operators would be silly to use with a literal
NaN
. I'm not sure whether it would have been better to just add more exceptions (specifically for||
and&&
). The technique in this PR has the risk that if a new comparison operator is later added to the language (e.g.<=>
) then the rule will need to be updated. But it seemed better to me to limit the scope of the rule completely.CHANGELOG.md entry:
[bugfix]
use-isnan
now applies only to comparison operators