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: unnecessary eta abstraction while removing parameter #65217

Open
findleyr opened this issue Jan 22, 2024 · 0 comments
Open

x/tools/gopls: unnecessary eta abstraction while removing parameter #65217

findleyr opened this issue Jan 22, 2024 · 0 comments
Labels
gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

In CL 557496, we observed that removing an unused parameter resulted in an unnecessary eta abstraction:

From:

rewrites, err := getRewriteCodeActions(snapshot, pkg, pgf, fh, rng, snapshot.Options())

To:

rewrites, err := func() (_ []protocol.CodeAction, rerr error) {
	var options *settings.Options = snapshot.Options()
	return getRewriteCodeActions(pkg, pgf, fh, rng, options)
}()

In this case, I'm sure it's the effect detection that triggers the literalization, but that's not correct. There is no change in effects before and after the parameter is removed, since the unused parameter has no side effects.

This is probably an artifact of how parameter removal is implemented via inlined wrappers.

CC @adonovan @suzmue

@findleyr findleyr added this to the gopls/v0.16.0 milestone Jan 22, 2024
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jan 22, 2024
@suzmue suzmue added the Refactoring Issues related to refactoring tools label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools 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