golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
121.05k stars 17.36k forks source link

gopls/internal/analysis: noresultvalues diagnostic triggers "end > end of file + 1" bug (via telemetry) #68105

Open adonovan opened 1 week ago

adonovan commented 1 week ago

This stack lMZltw was reported by telemetry:

noresultvalues reports a diagnostic with an End position well beyond EOF:

            pass.Report(analysis.Diagnostic{
                Pos:     err.Pos,
                End:     analysisinternal.TypeErrorEndPos(pass.Fset, buf.Bytes(), err.Pos),
                Message: err.Msg,
                SuggestedFixes: []analysis.SuggestedFix{{
                    Message: "Delete return values",
                    TextEdits: []analysis.TextEdit{{
                        Pos:     retStmt.Pos(),
                        End:     retStmt.End(),
                        NewText: []byte("return"),
                    }},
                }},
            })

The file was not "fixed", i.e. it is unmodified parser output.

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.(*action).exec.func2:+78
golang.org/x/tools/gopls/internal/cache.toGobDiagnostic:+32
golang.org/x/tools/gopls/internal/cache.(*action).exec.func3:+1
golang.org/x/tools/gopls/internal/analysis/noresultvalues.run.func1:+25
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder:+11
golang.org/x/tools/gopls/internal/analysis/noresultvalues.run:+7
golang.org/x/tools/gopls/internal/cache.(*action).exec.func7:+31
golang.org/x/tools/gopls/internal/cache.(*action).exec:+277
golang.org/x/tools/gopls/internal/cache.execActions.func1.1:+2
sync.(*Once).doSlow:+5
sync.(*Once).Do:=65
golang.org/x/tools/gopls/internal/cache.execActions.func1:+2
runtime.goexit:+0
golang.org/x/tools/gopls@v0.16.0-pre.1 go1.22.4 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

gabyhelp commented 1 week ago

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)