Skip to content

x/tools/gopls/internal/analysis/modernize: mapsloop loses commentary #72958

@adonovan

Description

@adonovan

The mapsloop transformation discards comments:

diff --git a/src/go/doc/reader.go b/src/go/doc/reader.go
index e84d6d9a71..6e8c682087 100644
--- a/src/go/doc/reader.go
+++ b/src/go/doc/reader.go
-                       for name, f := range t.funcs {
-                               // in a correct AST, package-level function names
-                               // are all different - no need to check for conflicts
-                               r.funcs[name] = f
-                       }
+                       maps.Copy(r.funcs, t.funcs)

Until recently, minmax used to do the same (#72727). We should apply a similar fix, here and anywhere else that discards a block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)BugReportIssues describing a possible bug in the Go implementation.NeedsFixThe path to resolution is known, but the work has not been done.RefactoringIssues related to refactoring toolsgopls/imports

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions