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: incorrect placeholders for aliased types #33500

Open
ChrisHines opened this issue Aug 6, 2019 · 1 comment

Comments

@ChrisHines
Copy link
Contributor

commented Aug 6, 2019

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

golang.org/x/tools/gopls v0.1.3
    golang.org/x/tools/gopls@v0.1.4-0.20190806194950-6743d4095d4b h1:2RQrzcrEYVmfqqLlivm/WQAKgrN3esjyGgkI4UhN/a0=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20190723021737-8bb11ff117ca h1:SqwJrz6xPBlCUltcEHz2/p01HRPR+VGD+aYLikk8uas=

Go info
-------
go version go1.12.7 darwin/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/chines209/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/chines209/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=""
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/zs/qv8flyxx1zl_nmdkklb5p15sz6zd1t/T/go-build867357531=/tmp/go-build -gno-record-gcc-switches -fno-common"

Does this issue reproduce with the latest release?

Yes.

What did you do?

I declared a function type struct field. The function has a parameter and return value with a type that is an exported alias of a type in an internal package my code doesn't have access to. For example:

import "golang.org/x/net/ipv4"

type mockAppender struct {
	appendMessages func(now time.Time, ms []ipv4.Message) ([]ipv4.Message, bool)
	stopped        func()
}

I then declare type literals for mockAppender in VSCode with the gopls.usePlaceholders option enabled.

What did you expect to see?

When I type a struct literal for the above type and add the appendMessages field, I expect the generated placeholder to reference types my code has access to, specifically:

ma := mockAppender{
	appendMessages: // placeholder -> func(now time.Time, ms []ipv4.Message) ([]ipv4.Message, bool, StepTime),
}

What did you see instead?

A placeholder that referenced types from a package my code cannot import that is type that ipv4.Message aliases. Specifically:

ma := mockAppender{
	appendMessages: // placeholder -> func(now time.Time, ms []socket.Message) ([]socket.Message, bool, StepTime),
}

@gopherbot gopherbot added this to the Unreleased milestone Aug 6, 2019

@gopherbot gopherbot added the gopls label Aug 6, 2019

@stamblerre stamblerre changed the title x/tools/gopls: placeholders for aliased types not right x/tools/gopls: incorrect placeholders for aliased types Aug 7, 2019

@stamblerre

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2019

Thanks for filing this issue! This is lower priority for us, so while I will try to fix this when I get a chance, if anyone else is interested in contributing a fix for this, please go ahead!

@stamblerre stamblerre removed the Suggested label Aug 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.