[tools] go/analysis/passes/modernize: stditerators: even better name heuristic

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Nov 11, 2025, 12:09:15 PM (yesterday) Nov 11
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Robert Findley, golang-co...@googlegroups.com

Alan Donovan submitted the change

Unreviewed changes

3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
go/analysis/passes/modernize: stditerators: even better name heuristic

This CL causes stditerators to generate a fresh name only when
the preferred name is already declared _and_ is free in
(referenced within) the loop body. This eliminates most cases
where a fresh (ugly) name is needed.

(Most places that use FreshName should do something similar,
though some care will be required to figure out the correct
abstraction.)

Fixes golang/go#76240
Updates golang/go#76241
Change-Id: Ia7a3332ef49e3d4f2934e9f85215b9373226084a
Reviewed-by: Robert Findley <rfin...@google.com>
Files:
  • M go/analysis/passes/modernize/errorsastype.go
  • M go/analysis/passes/modernize/stditerators.go
  • M go/analysis/passes/modernize/stringscut.go
  • M go/analysis/passes/modernize/stringscutprefix.go
  • M go/analysis/passes/modernize/testdata/src/stditerators/stditerators.go
  • M go/analysis/passes/modernize/testdata/src/stditerators/stditerators.go.golden
  • M internal/refactor/refactor.go
Change size: M
Delta: 7 files changed, 73 insertions(+), 4 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Robert Findley
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ia7a3332ef49e3d4f2934e9f85215b9373226084a
Gerrit-Change-Number: 719321
Gerrit-PatchSet: 5
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages