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

x/tools/go/analysis/passes/bools: analyzer warning is not descriptive enough #61157

Open
synenka opened this issue Jul 3, 2023 · 4 comments
Open
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@synenka
Copy link

synenka commented Jul 3, 2023

What did you do?

I have written code that triggers 'bools' analyzer warning

What did you expect to see?

Warning explains the issue

What did you see instead?

"Content: suspect or: rt != some_value || rt != another_value"

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 3, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jul 3, 2023
@ghost
Copy link

ghost commented Jul 3, 2023

Can you showcase some example code that triggers this behavior?

@timothy-king
Copy link
Contributor

Are some_value and another_value the same constant value? (Also is there a chance that the values of some_value and another_value` are build dependent?)

@synenka
Copy link
Author

synenka commented Jul 4, 2023

To add more context, we have internal bug(http://b/198584074) asking to make warnings more descriptive.

Analysis warning would be triggered by of expressions of type:

e && e // the same as e
e || e // the same as e
x != c1 || x != c2 // always true
x == c1 && x == c2 // always false

Where x is variable; c1, c2 are constants and c1 != c2

I also created CL to change this: http://go.dev/cl/507675

@timothy-king timothy-king added help wanted Analysis Issues related to static analysis (vet, x/tools/go/analysis) labels Jul 6, 2023
@timothy-king
Copy link
Contributor

If someone can suggest a sufficiently terse that is correct warning message that is clearer, I think it is fine to change the error message for this case.

@joedian joedian added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants