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

Improve handling for token.{LEQ,GEQ} for constant-logical-expr lint #641

Closed
shmsr opened this issue Feb 26, 2022 · 1 comment · Fixed by #642
Closed

Improve handling for token.{LEQ,GEQ} for constant-logical-expr lint #641

shmsr opened this issue Feb 26, 2022 · 1 comment · Fixed by #642
Labels

Comments

@shmsr
Copy link
Contributor

shmsr commented Feb 26, 2022

Describe the bug
From revive/testdata/constant-logical-expr.go:

func foo3(f float64) bool { return f <= f } // MATCH /expression always evaluates to false/

func foo4(f float64) bool { return f >= f } // MATCH /expression always evaluates to false/

But, for a binary expression with both operands being equal, it is expected that token.{EQL,LEQ,GEQ} should return true instead of false.

To Reproduce
Look at the testdata/constant-logical-expr.go and the implementation for constant-logical-expr. No need to reproduce it as it can be seen clearly from the example I've presented.

Expected behavior

func foo3(f float64) bool { return f <= f } // MATCH /expression always evaluates to true/

func foo4(f float64) bool { return f >= f } // MATCH /expression always evaluates to true/

Desktop (please complete the following information):

  • OS: Mac OSX
  • Go 1.17.6
@shmsr shmsr changed the title Improve handling for token.{NEQ,GEQ} for constant-logical-expr lint Improve handling for token.{LEQ,GEQ} for constant-logical-expr lint Feb 26, 2022
@chavacava
Copy link
Collaborator

Hi @shmsr, thanks for filling the issue and for the PR

@chavacava chavacava added the bug label Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants