Skip to content

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

Closed
@adonovan

Description

@adonovan
#!stacks
"bug.Reportf" && "cache.(*action).exec.func2:+78"
		if end > fileEnd+1 {
			if !fixed {
				bug.Reportf("end > end of file + 1")
			}
			end = fileEnd
		}

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/[email protected] go1.22.4 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
Dups: PFz3wQ uU3LXw s5dvOQ v7eTGw euXauA jAlTmg Ube-fg 20eLzA

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/telemetry-wins

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions