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: find references on builtin types returns wrong results #32991

Closed
suzmue opened this issue Jul 8, 2019 · 1 comment
Closed

x/tools/gopls: find references on builtin types returns wrong results #32991

suzmue opened this issue Jul 8, 2019 · 1 comment
Labels
Milestone

Comments

@suzmue
Copy link
Contributor

@suzmue suzmue commented Jul 8, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.5 darwin/amd64

$ gopls version
golang.org/x/tools/gopls v0.1.1

also reproduces at master:
$ gopls version
golang.org/x/tools/gopls v0.1.1
    golang.org/x/tools/gopls@v0.1.2-0.20190708200955-c93f28baaae0

Does this issue reproduce with the latest release?

Yes. Reproduces at master as well.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/suzmue/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/suzmue/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/suzmue/go/src/golang.org/x/tools/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/q0/0bxb5hrs08l_vhzptkl5gd2400fkl_/T/go-build594969232=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Find references on int, string, bool, and nil.

package gopkg

type myInt int // refs "int"

func hello(x string) []bool {  // refs "string", refs "bool"
	return nil // refs "nil"
}

What did you expect to see?

Only references to the same type.

What did you see instead?

All of [int, string, bool, nil] are returned as a result of references when called on any of these builtin types.

@gopherbot gopherbot added this to the Unreleased milestone Jul 8, 2019
@gopherbot gopherbot added the gopls label Jul 8, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jul 9, 2019

Change https://golang.org/cl/185247 mentions this issue: internal/lsp: compare names when finding references

movie-travel-code added a commit to movie-travel-code/tools that referenced this issue Jul 11, 2019
Objects for builtin types all have position token.NoPos. We do
not want all objects that have position token.NoPos to be matched
when we are looking for references for this object, so we need to
compare the names of the objects as well.

Fixes golang/go#32991

Change-Id: I67e7aba9909ebcbb246203ea5c572debf996c792
Reviewed-on: https://go-review.googlesource.com/c/tools/+/185247
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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