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: using '.' as -from package causes panic #13866

Closed
ericchiang opened this issue Jan 8, 2016 · 3 comments
Closed

x/tools/cmd/gorename: using '.' as -from package causes panic #13866

ericchiang opened this issue Jan 8, 2016 · 3 comments

Comments

@ericchiang
Copy link
Contributor

Don't know if using a '.' as the -from package is supposed to be legal but I ran into a panic doing so.

$ cd $GOPATH/src/foo
$ ls
hello.go
$ cat hello.go
package main

func sayHello() {
}

func main() {
}
$ gorename -from '".".sayHello' -to 'sayGoodbye'
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4a6812]

goroutine 1 [running]:
golang.org/x/tools/refactor/rename.findObjects(0x0, 0xc8200aea10, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/eric/src/golang.org/x/tools/refactor/rename/spec.go:419 +0x352
golang.org/x/tools/refactor/rename.findFromObjects(0xc82001a800, 0xc8200aea10, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/eric/src/golang.org/x/tools/refactor/rename/spec.go:292 +0x1ed
golang.org/x/tools/refactor/rename.Main(0x88bd00, 0x0, 0x0, 0x7ffeacf52f39, 0xc, 0x7ffeacf52f4a, 0xa, 0x0, 0x0)
    /home/eric/src/golang.org/x/tools/refactor/rename/rename.go:253 +0x625
main.main()
    /home/eric/src/golang.org/x/tools/cmd/gorename/main.go:49 +0x337

This is using the latest checkout of golang/tools.

@griesemer
Copy link
Contributor

I think the command shouldn't crash and I would consider this a bug.

@ericchiang
Copy link
Contributor Author

It looks like the loader is loading the package just fine, but findFromObjects does map lookup using the package name "." here producing a nil *loader.PackageInfo

@alandonovan
Copy link
Contributor

@golang golang locked and limited conversation to collaborators Jan 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants