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: undeclared name, "has no field" after converting function to method #36224

Closed
zikaeroh opened this issue Dec 19, 2019 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zikaeroh
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

I was swapping a function to a method by converting an argument to the receiver.

Specifically func handleSession(ctx context.Context, s *session) error into func (s *session) handleSession(ctx context.Context) error: https://github.com/hortbot/hortbot/blob/4d6695f4a2c859aacfca5867ac5167e765a7dad9/internal/bot/handle.go#L246

What did you expect to see?

No errors.

What did you see instead?

Once I changed that and modified the function's uses, my global variables disappear from the package, and some methods stop working.

Logs: https://gist.github.com/zikaeroh/3bcf06b0d743684137cd839c6b572460

Bisect says:

85a3356613b8bd50e1fc3106adf38091f293ac9b is the first bad commit
commit 85a3356613b8bd50e1fc3106adf38091f293ac9b
Author: Rebecca Stambler <rstambler@golang.org>
Date:   Thu Dec 19 00:59:50 2019 -0500

    internal/lsp/cache: consolidate function to update overlays
    
    This change merges the small helper functions that modified overlays
    into a single function and removes the openFiles sync.Map in the view.
    
    Change-Id: Id94c7d86228c9628b7373fab0030ad0c8018dda5
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/212037
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: Heschi Kreinick <heschi@google.com>

 internal/lsp/cache/debug.go   |   9 ----
 internal/lsp/cache/overlay.go | 109 ++++++++++++++++--------------------------
 internal/lsp/cache/session.go |  29 ++++-------
 3 files changed, 48 insertions(+), 99 deletions(-)

Build info

golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@(devel)
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20191017151554-a3bc800455d5 => ../
    golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
    honnef.co/go/tools@v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=

Go info

go version go1.13.5 linux/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jake/.cache/go-build"
GOENV="/home/jake/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jake/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jake/zikaeroh/hortbot/hortbot/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build738506478=/tmp/go-build -gno-record-gcc-switches"
@gopherbot gopherbot added this to the Unreleased milestone Dec 19, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Dec 19, 2019
@gopherbot
Copy link

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Dec 19, 2019
@gopherbot
Copy link

Change https://golang.org/cl/212199 mentions this issue: internal/lsp: don't clear file contents on save

@golang golang locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. 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