Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adonovan opened this issue Jun 21, 2024 · 4 comments
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. 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

Comments

@adonovan
Copy link
Member

adonovan commented Jun 21, 2024

#!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/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.
Dups: PFz3wQ uU3LXw

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Jun 21, 2024
@adonovan adonovan added this to the gopls/v0.17.0 milestone Jun 21, 2024
@findleyr
Copy link
Contributor

This is probably a bit gnarly to track down, though surely it's a go/parser bug. Bumping to v0.18, when hopefully we can fix go/parser.

@findleyr findleyr modified the milestones: gopls/v0.17.0, gopls/v0.18.0 Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. 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.
Projects
None yet
Development

No branches or pull requests

3 participants