all: test: remove unneeded loop variables#77694
all: test: remove unneeded loop variables#77694ariel-anieli wants to merge 1 commit intogolang:masterfrom
Conversation
|
This PR (HEAD: f7c955d) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/746502. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Ariel Otilibili Anieli: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Alan Donovan: Patch Set 2: Code-Review+2 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Jorropo: Patch Set 2: Code-Review+2 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
This CL follows from the abandoned CL 722961.
Alan Donovan asked if modernize would catch these changes; it does in part.
Here is how modernize was used:
1. Build the Go compiler from latest master
2. Clone x/tools and build modernize with the newest compiler
3. Then, do:
PATH=PATH_TO_BIN:$PATH go list ./... | xargs env PATH=PATH_TO_BIN:$PATH GOMOD=off MODERNIZE -forvar -fix -test -debug fpstv
4. For assurance, move into a package directory (i.e, cmd), and redo Step 3.
From the obtained result, it seems modernize did not remove the loop variable when:
- the range notation was not used
- the loop variable was not directly under the for directive.
Which does happens here:
# git ls-files | xargs -I {} perl -nE 'print "$ARGV:$.:$_" if /\s+(\w+) := \1$/' {} | grep _test
[...]
cmd/compile/internal/types2/api_test.go:2423: i := i
md/go/internal/modload/query_test.go:182: tt := tt
md/go/internal/web/url_test.go:17: tc := tc
cmd/go/internal/web/url_test.go:49: tc := tc
cmd/internal/par/queue_test.go:54: i := i
runtime/syscall_windows_test.go:781: arglen := arglen
Fixes golang#76411.
Link: https://go-review.googlesource.com/c/go/+/722961/comments/e8d47866_fc399fa1
Co-authored-by: Plamerdi Makela <plamerdi447@gmail.com>
f7c955d to
77c3e11
Compare
|
This PR (HEAD: 77c3e11) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/746502. Important tips:
|
|
Message from Ariel Otilibili Anieli: Patch Set 2: (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Alan Donovan: Patch Set 3: Auto-Submit+1 Code-Review+2 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Go LUCI: Patch Set 3: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-02-24T01:27:29Z","revision":"7d4f8be5469fd932cde049312a9f2a967e4eb894"} Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Alan Donovan: Patch Set 3: -Commit-Queue (Performed by golang-scoped@luci-project-accounts.iam.gserviceaccount.com on behalf of adonovan@google.com) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Go LUCI: Patch Set 3: This CL has failed the run. Reason: Failed Tryjobs:
To reproduce, try Additional links for debugging:
To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Go LUCI: Patch Set 3: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Ariel Otilibili Anieli: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Alan Donovan: Patch Set 4: Auto-Submit+1 Code-Review+2 Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Go LUCI: Patch Set 4: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-02-24T01:47:51Z","revision":"0836553c6a25aeafeafbc56603e2935a3a1bd648"} Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Ariel Otilibili Anieli: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Alan Donovan: Patch Set 4: -Commit-Queue (Performed by golang-scoped@luci-project-accounts.iam.gserviceaccount.com on behalf of adonovan@google.com) Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Go LUCI: Patch Set 4: This CL has failed the run. Reason: Tryjob golang/try/gotip-linux-amd64-boringcrypto has failed with summary (view all results):
To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
|
Message from Go LUCI: Patch Set 4: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/746502. |
This CL follows from the abandoned CL 722961.
Alan Donovan asked if modernize would catch these changes; it does in part.
Here is how modernize was used:
Build the Go compiler from latest master
Clone x/tools and build modernize with the newest compiler
Then, do:
PATH=PATH_TO_BIN:$PATH go list ./... | xargs env PATH=PATH_TO_BIN:$PATH GOMOD=off MODERNIZE -forvar -fix -test -debug fpstv
For assurance, move into a package directory (i.e, cmd), and redo Step 3.
From the obtained result, it seems modernize did not remove the loop variable when:
Which does happens here:
Link: https://go-review.googlesource.com/c/go/+/722961/comments/e8d47866_fc399fa1
Co-authored-by: Plamerdi Makela plamerdi447@gmail.com
Fixes #76411