Commit bf12eb7
gopls/internal/analysis/modernize: fix slicedelete triggers on slice identifiers with side effects
Add a check that the expression defining the slice has no side effects to trigger slicedelete. This is a necessary condition to ensure that the change does not change the program behavior.
Fixes golang/go#72955
Change-Id: Ic326baa37e0b621fa7ba204bbfeb61c3e7daea47
GitHub-Last-Rev: 54e9082
GitHub-Pull-Request: #567
Reviewed-on: https://go-review.googlesource.com/c/tools/+/659295
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>1 parent ec542a7 commit bf12eb7
File tree
6 files changed
+78
-18
lines changed- gopls/internal/analysis/modernize
- testdata/src/slicesdelete
6 files changed
+78
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| |||
Lines changed: 25 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | | - | |
9 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
10 | 18 | | |
11 | | - | |
| 19 | + | |
12 | 20 | | |
13 | | - | |
| 21 | + | |
14 | 22 | | |
15 | | - | |
| 23 | + | |
16 | 24 | | |
17 | | - | |
| 25 | + | |
18 | 26 | | |
19 | | - | |
| 27 | + | |
20 | 28 | | |
21 | | - | |
| 29 | + | |
22 | 30 | | |
23 | | - | |
| 31 | + | |
24 | 32 | | |
25 | | - | |
| 33 | + | |
26 | 34 | | |
27 | | - | |
| 35 | + | |
28 | 36 | | |
29 | | - | |
| 37 | + | |
30 | 38 | | |
31 | | - | |
| 39 | + | |
32 | 40 | | |
33 | | - | |
| 41 | + | |
34 | 42 | | |
35 | | - | |
| 43 | + | |
36 | 44 | | |
37 | | - | |
38 | | - | |
| 45 | + | |
| 46 | + | |
0 commit comments