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/go/analysis/cmd/vet: also whitelist unicode.Range32 to avoid "unkeyed fields in composite literal" error #32507

Closed
adiabatic opened this issue Jun 9, 2019 · 3 comments
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@adiabatic
Copy link

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

$ go version
go version go1.12.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes. 1.12.5 is the latest release available for macOS on golang.org/dl/.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/comatoast/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/comatoast/Projects/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/comatoast/Projects/quote-educator/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/wy/3sprnnbj2yx9h60jbs4qjvpr0000gn/T/go-build895608949=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I used struct literals without keys. go vet doesn't complain when it sees unicode.Range16{0xfdd0, 0xfdef, 1}, but complains when it sees unicode.Range32{0x1fffe, 0x1ffff, 1}.

Minimized test case: https://play.golang.org/p/atnHOc10YRs

Semi-minimized real-world example: https://play.golang.org/p/VzaW9okIUic

What did you expect to see?

No go vet errors. Or, now that I've researched a bit into how go vet should work, errors for using unicode.Range16 like this, too.

What did you see instead?

go vet errors on lines like unicode.Range32{0x1fffe, 0x1ffff, 1}. After seeing the discussion on #6820 I'm not sure why unicode.Range16 is fine but unicode.Range32 is warning-worthy.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 10, 2019
@ianlancetaylor ianlancetaylor added this to the Go1.14 milestone Jun 10, 2019
@letientai299
Copy link
Contributor

I've submitted a CL for this: https://go-review.googlesource.com/c/tools/+/180922

@gopherbot
Copy link

Change https://golang.org/cl/180922 mentions this issue: vet: whitelist unicode.Range32

adiabatic added a commit to adiabatic/quote-educator that referenced this issue Jun 11, 2019
@odeke-em odeke-em changed the title cmd/vet: reporting "unicode.Range32 composite literal uses unkeyed fields", but not for unicode.Range16 x/tools/go/analysis/cmd/vet: reporting "unicode.Range32 composite literal uses unkeyed fields", but not for unicode.Range16 Jun 13, 2019
@odeke-em
Copy link
Member

Thank you for this report @adiabatic and for working on the fix @letientai299!

Since this cmd/vet is now under x/tools/go/analysis/cmd/vet https://github.com/golang/tools/tree/master/go/analysis/cmd/vet we can put this under the Unreleased milestone and it can get in at anytime.

@odeke-em odeke-em modified the milestones: Go1.14, Unreleased Jun 13, 2019
@odeke-em odeke-em changed the title x/tools/go/analysis/cmd/vet: reporting "unicode.Range32 composite literal uses unkeyed fields", but not for unicode.Range16 x/tools/go/analysis/cmd/vet: also whitelist unicode.Range32 to avoid "unkeyed fields in composite literal" error Jun 13, 2019
@golang golang locked and limited conversation to collaborators Jun 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants