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

x/tools/gopls/internal/analysis/unusedvariable: reports invalid SuggestedFixes #71812

Open
adonovan opened this issue Feb 18, 2025 · 4 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. 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 Feb 18, 2025

#!stacks
"bug.Reportf" && "cache.(*action).exec.func3:+3" && "unusedvariable.runForError:+37"

Issue created by stacks.

			// Find GenDecl to which offending ValueSpec belongs.
			if decl, ok := path[i+1].(*ast.GenDecl); ok {
				fixes := removeVariableFromSpec(pass, path, stmt, decl, ident)
				// fixes may be nil
				if len(fixes) > 0 {
					diag.SuggestedFixes = fixes
					pass.Report(diag)                         <--- here
				}
			}

This stack JfZhUw was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.6 windows/amd64 vscode (1)

Dups: k4vfuQ

@adonovan adonovan added gopls Issues related to the Go language server, gopls. gopls/telemetry-wins 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. labels Feb 18, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 18, 2025
@adonovan
Copy link
Member Author

This stack Gf7EXQ was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.5 windows/amd64 vscode (1)
golang.org/x/tools/[email protected] go1.23.6 darwin/arm64 vscode,vscode-insiders (1)
golang.org/x/tools/[email protected] go1.23.5 darwin/amd64 vscode (1)
golang.org/x/tools/[email protected] go1.23.6 windows/amd64 other,vscode (1)
golang.org/x/tools/[email protected] go1.23.6 linux/amd64 vscode (4)
golang.org/x/tools/[email protected] go1.23.6 windows/amd64 vscode (1)
golang.org/x/tools/[email protected] go1.23.4 darwin/arm64 vscode (1)
golang.org/x/tools/[email protected] go1.23.6 windows/amd64 vscode (2)
golang.org/x/tools/[email protected] go1.23.4 darwin/arm64 vscode (1)
golang.org/x/tools/[email protected] go1.23.4 windows/amd64 vscode (1)
golang.org/x/tools/[email protected] go1.23.5 windows/amd64 other,vscode (1)
golang.org/x/tools/[email protected] go1.23.4 linux/amd64 vscode (2)
golang.org/x/tools/[email protected] go1.23.6 darwin/arm64 other (1)
golang.org/x/tools/[email protected] go1.23.4 windows/amd64 other,vscode (1)

This stack JuVvTw was reported by telemetry:

golang.org/x/tools/[email protected] go1.24.0 windows/amd64 vscode (1)
golang.org/x/tools/[email protected] go1.24rc3 darwin/arm64 sublimetext (1)

This stack KznUPA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.6 darwin/arm64 vscode (1)

This stack EmaIvQ was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.6 linux/amd64 vscode (1)

This stack 10HCWA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.6 darwin/arm64 other,vscode (1)
golang.org/x/tools/[email protected] go1.23.6 darwin/arm64 vscode,vscode-insiders (1)
golang.org/x/tools/[email protected] go1.23.5 windows/amd64 vscode (1)

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Feb 18, 2025
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.18.1 Feb 18, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/650395 mentions this issue: gopls/internal/analysis/unusedvariable: refine bug.Report golang/go#71812

gopherbot pushed a commit to golang/tools that referenced this issue Feb 18, 2025
…1812

This CL adds assertions to refine the bug reported in golang/go#71812,
in which the analyzer reports an invalid SuggestedFix.

Updates golang/go#71812

Change-Id: Ie4a9aac9ba3d16974320d7cd4b48bc4cc76fc3c4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/650395
Commit-Queue: Alan Donovan <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
Auto-Submit: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
github-actions bot added a commit to satorunooshie/go-tools that referenced this issue Feb 18, 2025
776604a9e gopls/internal/analysis/modernize: sortslice: fix crash
df7baa073 gopls/internal/analysis/simplifyrange: more precise fix
ad5dd9875 gopls: fix a few bugs related to the new modcache imports source
4b3fdfd83 go/analysis/passes/printf: suppress diagnostic for Println("...%XX...")
fe883a85d gopls/internal/analysis/unusedvariable: refine bug.Report golang/go#71812
d115b345e gopls/internal/analysis: simplify type-error analyzers with Cursor
c18bffa1b all: delete redundant //go:debug gotypesalias=1 directives [generated]
94db71079 all: upgrade go directive to at least 1.23.0 [generated]

git-subtree-dir: golang.org/x/tools
git-subtree-split: 776604a9ed881ee1274724fb3a5f058f3ebdf0eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. 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

4 participants