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/ssa: panic in ssa.(*Program).needMethods with type parameters #50078

Closed
ainar-g opened this issue Dec 9, 2021 · 1 comment
Closed
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Dec 9, 2021

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

$ go version
go version devel go1.18-78b4518e31 Thu Dec 9 17:16:12 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ainar/.cache/go-build"
GOENV="/home/ainar/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ainar/go/pkg/mod"
GONOPROXY="REMOVED"
GONOSUMDB="REMOVED"
GOOS="linux"
GOPATH="/home/ainar/go"
GOPRIVATE="REMOVED"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ainar/go/tip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ainar/go/tip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-78b4518e31 Thu Dec 9 17:16:12 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/home/ainar/dev/tmp/go/tmp/go.mod"
GOWORK=""
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=/tmp/go-build3880243860=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. Install any analyser that uses golang.org/x/tools/go/ssa. I've tried nilness and unparam.

  2. Try running it on the following code:

    package main
    
    import "fmt"
    
    func main() {
    	F(42)
    }
    
    func F[T any](v T) {
    	fmt.Println(v)
    }

What did you expect to see?

No errors.

What did you see instead?

nilness .
panic: T

goroutine 354 [running]:
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc00022a9c0, {0x7b5a60?, 0xc000116900?}, 0x0)
        /home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.9-0.20211209154716-27fc7644e1ac/go/ssa/methods.go:237 +0x5b1
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc00022a9c0, {0x7b5a38?, 0xc0004629d8?}, 0x0)
        /home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.9-0.20211209154716-27fc7644e1ac/go/ssa/methods.go:233 +0x708
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc00022a9c0, {0x7b59c0?, 0xc0006bde80?}, 0x0)
        /home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.9-0.20211209154716-27fc7644e1ac/go/ssa/methods.go:209 +0x448
golang.org/x/tools/go/ssa.(*Program).needMethodsOf(0xc00022a9c0, {0x7b59c0?, 0xc0006bde80?})
        /home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.9-0.20211209154716-27fc7644e1ac/go/ssa/methods.go:145 +0x70
golang.org/x/tools/go/ssa.(*Package).build(0xc0000ec240)
        /home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.9-0.20211209154716-27fc7644e1ac/go/ssa/builder.go:2281 +0x111
sync.(*Once).doSlow(0xc00022a9c0?, 0xc00027f450?)
        /home/ainar/go/tip/src/sync/once.go:68 +0xc2
[…]
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Dec 9, 2021
@gopherbot gopherbot added this to the Unreleased milestone Dec 9, 2021
@timothy-king
Copy link
Contributor

Duplicate of #48525. x/tools/go/ssa and packages based on it, like nilness, do not yet support code containing generics. FWIW I am actively working to address this.

@golang golang locked and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants