Change information
Commit message:
go/analysis/passes/modernize: stringscut: detect modifying use in all assignments
In the stringscut modernizer, we skip suggesting a fix if any of the uses of the input variable "s" (after the call to Index) are modifying uses, as a fix would not preserve the existing semantics.
When looking at a use of "s" in an assignment, we previously only check Lhs[0]. If the "s" is modified in a multi-assignment but is not the first variable in the list, we will miss this modifying use and may end up suggesting an invalid fix.
Instead, we should treat any use of "s" on the lhs as a modifying use.
Change-Id: I4ba58d720f2df2db3fca71927d0704cbb9e8813d
Files:
- M go/analysis/passes/modernize/stringscut.go
- M go/analysis/passes/modernize/testdata/src/stringscut/stringscut.go
- M go/analysis/passes/modernize/testdata/src/stringscut/stringscut.go.golden
Change size: S
Delta: 3 files changed, 26 insertions(+), 7 deletions(-)
Branch: refs/heads/master