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/cmd/gorename: keyword as identifier #16535

Closed
SmallRoomLabs opened this issue Jul 29, 2016 · 1 comment
Closed

x/tools/cmd/gorename: keyword as identifier #16535

SmallRoomLabs opened this issue Jul 29, 2016 · 1 comment
Milestone

Comments

@SmallRoomLabs
Copy link

@SmallRoomLabs SmallRoomLabs commented Jul 29, 2016

While refactoring some code written a bit too C-stylish with constants in uppercase I by mistake renamed a constant named SWITCH to switch. This particular operation was successful but the next rename failed.

I remember reading that gorename should take a well-typed program and either return an error or another well-typed program as its output. But in this case it broke the code for me by my own stupidity.

Would it be possible to have gorename check for reserved keywords before applying the requested changes?

package main
func main() {
    SWITCH := "X"
    _ = SWITCH
}

Renaming the variable SWITCH to lowercase and then trying to rename it to something else.

$ gorename -from 'main.go::SWITCH' -to switch
Renamed 2 occurrences in 1 file in 1 package.

$ gorename -from 'main.go::switch' -to toggleSwitch
/Users/matseng/gocode/src/github.com/smallroomlabs/bug1/main.go:4:9: expected operand, found ':=' (and 2 more errors)
gorename: couldn't load packages due to errors: github.com/smallroomlabs/bug1
@quentinmit quentinmit added this to the Unreleased milestone Jul 29, 2016
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 1, 2016

CL https://golang.org/cl/25343 mentions this issue.

@golang golang locked and limited conversation to collaborators Aug 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.