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: unnecessary autocomplete of int() cast inside array index #44268

Closed
evanw opened this issue Feb 15, 2021 · 2 comments
Closed

x/tools/gopls: unnecessary autocomplete of int() cast inside array index #44268

evanw opened this issue Feb 15, 2021 · 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

@evanw
Copy link

evanw commented Feb 15, 2021

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

$ go version
go version go1.15.7 darwin/amd64

Does this issue reproduce with the latest release?

I'm on the latest version of the Go VSCode extension (0.22.1) which from what I understand is now using gopls.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/evan/Library/Caches/go-build"
GOENV="/Users/evan/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/evan/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/evan/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
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/j6/np400cw17sz0n5ljd67byrzw0000gn/T/go-build549777181=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

The automatic cast insertion in VSCode inserts unnecessary int() casts inside array index expressions:

I keep having to delete these automatically inserted casts after autocompleting. While they don't alter the semantics of the code, they are visually noisy and I would prefer to not have them.

What did you expect to see?

I would expect autocomplete to not insert explicit casts wherever the language supports implicit casts.

What did you see instead?

It looks like the autocomplete feature of gopls always inserts explicit casts even when they are unnecessary.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Feb 15, 2021
@gopherbot gopherbot added this to the Unreleased milestone Feb 15, 2021
@muirdm
Copy link

muirdm commented Feb 16, 2021

This should be fixed on master via https://go-review.googlesource.com/c/tools/+/289272. Hopefully there will be a release this week.

@stamblerre
Copy link
Contributor

Confirmed that this is fixed at master, and it will be part of the v0.6.6 release today.

@golang golang locked and limited conversation to collaborators Feb 22, 2022
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

4 participants