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

go/types: tip: math/all_test.go:1963:2: constant overflow #45874

Closed
dominikh opened this issue Apr 30, 2021 · 6 comments
Closed

go/types: tip: math/all_test.go:1963:2: constant overflow #45874

dominikh opened this issue Apr 30, 2021 · 6 comments
Assignees
Labels
Milestone

Comments

@dominikh
Copy link
Member

@dominikh dominikh commented Apr 30, 2021

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

$ go version
go version devel go1.17-9c7207891c Fri Apr 30 05:18:37 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

No.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dominikh/.cache/go-build"
GOENV="/home/dominikh/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/dominikh/prj/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dominikh/prj"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/dominikh/prj/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/dominikh/prj/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.17-9c7207891c Fri Apr 30 05:18:37 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/dominikh/prj/src/sandbox/baz/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-build3029975122=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/9NB6JwDlteB

The issue does not reproduce with Go 1.16.2. I cannot reproduce it with go vet or gotype.go, either, unfortunately. This might be a misuse of the go/types API in Staticcheck, but I couldn't find any mistakes yet.

git bisect points at 168d6a4 (/cc @findleyr)

What did you expect to see?

math []
math [math.test] []
math_test [math.test] []
math.test []

What did you see instead?

math []
math [math.test] []
math_test [math.test] [/home/dominikh/prj/go/src/math/all_test.go:1963:2: constant  overflow]
math.test []
@cuonglm
Copy link
Member

@cuonglm cuonglm commented Apr 30, 2021

I think the problem is #45837

Your "honnef.co/go/tools/go/loader" use gcimporter, which currently has the same restriction with gc.

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Apr 30, 2021

Thanks for reporting, and for the repro. @cuonglm may be right -- I'll take a look.

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Apr 30, 2021

The problem is that gcimporter is not preserving the constant Kind. We've seen this before: this was fixed in x/tools in https://golang.org/cl/307590, but that fix did not make it in to honnef.co/go/tools.

@dominikh, what is your process for keeping in-sync with x/tools? Is this liable to bite users of staticcheck who may upgrade Go, but not staticcheck?

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Apr 30, 2021

Is this liable to bite users of staticcheck who may upgrade Go, but not staticcheck?

To clarify: is it common for users to install older versions of staticcheck, or do you see any other reasons why this problem is not fixable?

Loading

@dominikh
Copy link
Member Author

@dominikh dominikh commented Apr 30, 2021

is it common for users to install older versions of staticcheck

I don't believe so, and officially a Staticcheck release supports the last two releases of Go, and makes no promises about forward compatibility. Pulling in the changes and making a new release should fix the issue.

Presumably this issue can be closed, then?

I'm sorry for making you debug an issue that was ultimately in "my" code.

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Apr 30, 2021

No problem at all. This overflow check was a change in behavior in go/types (arguably a bug fix), and I wanted to understand its ramifications.

Yes, I think this can be closed now.

Loading

@findleyr findleyr closed this Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants