x/tools/go/analysis/passes/fieldalignment: mutates AST #68735
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Noticed in passing: the fieldalignment analyzer (which as of gopls/v0.17.0 is now used in x/tools only by its tests) potentially mutates the AST it is passed by the analysis framework:
x/tools/go/analysis/passes/fieldalignment/fieldalignment.go:
No analyzer should do that. Similar mutations in other analyzers could be a cause of a variety of bugs, inconsistencies, and crashes in tools such as gopls.
We should consider developing the deepHash approach used in x/tools/internal/refactor/inline/inline_test.go so that we can dynamically check for unwanted AST mutations around certain operations such as Analyzer.Run. (Of course, it is not cheap, and is only as good as the test coverage.)
The text was updated successfully, but these errors were encountered: