-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
When renaming a parameter using gopls's rename command, and the new name is identical to the name of an imported package referenced by one of the function parameters, gopls reports an error, even though the renaming might be sound. For example:
import "fmt"
func _(x fmt.Stringer) {} // rename x to "fmt" gives renaming this var "x" to "fmt" would shadow this reference to the imported package name declared here
(Unfortunately the pronouns in the error message don't actually link to source locations, at least not when I use Emacs+eglot.)
The same thing happens when the package is referenced by a later parameter (e.g. func(x int, y fmt.Stringer)) or by a named constant in an array type (e.g. func(x [math.MaxInt]bool)).
IIRC the gorename tool got this right.
Metadata
Metadata
Assignees
Labels
RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.