Proposals Unofficial Go proposal tracker

Support expectations for related information in want comments

#75800 · x/tools/go/analysis/analysistest · low impact · Accepted ·

Analyzer tests written with analysistest can check diagnostic messages and facts through // want comments. They cannot check a diagnostic's related information (analysis.Diagnostic.Related). Today, authors must inspect the returned Result by hand.

The proposal adds two things:

  • A new // anchor <name> comment that names a line.
  • A new want field, @<anchor>:<regexp>, which expects a related information entry on the anchored line whose message matches the regexp.
var x int // anchor decl

func f() {
    x := 1 // want "x shadows outer variable" @decl:"declared here"
}
Proposal
#75800 by tcard
Status
Accepted on Nov 11, 2026
Impact
low
Area
x/tools/go/analysis/analysistest