SA4006: Fix for compound operators, increment/decrement#1555
Open
arp242 wants to merge 1 commit intodominikh:masterfrom
Open
SA4006: Fix for compound operators, increment/decrement#1555arp242 wants to merge 1 commit intodominikh:masterfrom
arp242 wants to merge 1 commit intodominikh:masterfrom
Conversation
In the case of compound operators such as +=, -=, etc we need to use the left-hand side to get the value. For IncDec we need a different codepath from AssignStmt altogether. Fixes dominikh#1329
|
Thanks for implementing this @arp242! I skimmed the code and it makes sense to me, but I'm not too familiar with staticcheck internals since all my tools are built on top of the x/tools code. I ran this over a large code base and it worked fine and flagged one new unused write (thanks!). I tried running it against another instance of this bug that I found in a code review recently and it wasn't flagged by this code. But after some digging I see that it's a general shortcoming of the SA4006 implementation, not this PR; I filed #1609. Hopefully this can be incorporated into staticcheck soon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In the case of compound operators such as +=, -=, etc we need to use the left-hand side to get the value.
For IncDec we need a different codepath from AssignStmt altogether.
Fixes #1329