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: rename to unexported name succeeds for symbol referenced by external text #59403

Closed
adonovan opened this issue Apr 3, 2023 · 1 comment
Assignees
Labels
gopls/incremental 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

@adonovan
Copy link
Member

adonovan commented Apr 3, 2023

Renaming the exported field X to unexported x should fail because it is referenced by an external test, and the reference would be broken by the renaming. But it proceeds, and the reference is indeed broken.

xtools$ git log -1 | head -n 1
commit 902fdcadc132d6f7a844f6e6df47af75dd9b5d37 (HEAD -> master, origin/master, origin/HEAD)

xtools$ head ./repro/*go
==> ./repro/repro.go <==
package repro

var S struct{ X int }

==> ./repro/repro_test.go <==
package repro_test

import "golang.org/x/tools/repro"

var Y = repro.S.X

xtools$ go test ./repro
ok  	golang.org/x/tools/repro	(cached) [no tests to run]

xtools$ go run ./gopls rename -w ./repro/repro.go:#30 x
/Users/adonovan/w/xtools/repro/repro.go
/Users/adonovan/w/xtools/repro/repro_test.go

xtools$ head ./repro/*go
==> ./repro/repro.go <==
package repro

var S struct{ x int }

==> ./repro/repro_test.go <==
package repro_test

import "golang.org/x/tools/repro"

var Y = repro.S.x

xtools$ go test ./repro
# golang.org/x/tools/repro_test [golang.org/x/tools/repro.test]
repro/repro_test.go:5:17: repro.S.x undefined (type struct{x int} has no field or method x)
FAIL	golang.org/x/tools/repro [build failed]
FAIL
@adonovan adonovan self-assigned this Apr 3, 2023
@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 Apr 3, 2023
@gopherbot gopherbot added this to the Unreleased milestone Apr 3, 2023
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.12.0 Apr 4, 2023
@adonovan adonovan added the Refactoring Issues related to refactoring tools label Apr 24, 2023
@gopherbot
Copy link

Change https://go.dev/cl/494440 mentions this issue: gopls/internal/lsp/source: fix rename-to-unexported bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/incremental 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

2 participants