gcpug / zagane

zagane is a static analysis tool which can find bugs in spanner's code
MIT License
89 stars 15 forks source link

bug: panic with type parameters #47

Closed kawaguchisan closed 2 months ago

kawaguchisan commented 2 years ago

Go version

$ go version
go version go1.18.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What did you do?

Try running "zagane" in the following code.

// main.go
package main

import "fmt"

func main() {
    Print([]string{"xxx"})
}

func Print[T any](s []T) {
    for _, v := range s {
        fmt.Println(v)
    }
}

$ go vet -vettool=(which zagane) main.go

What did you expect to see?

No errors.

What did you see?

# command-line-arguments
panic: T

goroutine 17 [running]:
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc0000940d0, {0x132b478?, 0xc0001a21b0?}, 0x0)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/ssa/methods.go:237 +0x5b1
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc0000940d0, {0x132b400?, 0xc000063d40?}, 0x0)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/ssa/methods.go:196 +0x347
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc0000940d0, {0x132b450?, 0xc00000d1a0?}, 0x0)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/ssa/methods.go:233 +0x708
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc0000940d0, {0x132b3d8?, 0xc000198bc0?}, 0x0)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/ssa/methods.go:209 +0x448
golang.org/x/tools/go/ssa.(*Program).needMethodsOf(0xc0000940d0, {0x132b3d8?, 0xc000198bc0?})
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/ssa/methods.go:145 +0x70
golang.org/x/tools/go/ssa.(*Package).build(0xc000090360)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/ssa/builder.go:2284 +0x111
sync.(*Once).doSlow(0xc0000940d0?, 0xc0000776d0?)
        /Users/shota/.goenv/versions/1.18.2/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
        /Users/shota/.goenv/versions/1.18.2/src/sync/once.go:59
golang.org/x/tools/go/ssa.(*Package).Build(...)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/ssa/builder.go:2272
golang.org/x/tools/go/analysis/passes/buildssa.run(0xc000094000)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/analysis/passes/buildssa/buildssa.go:72 +0x2ee
golang.org/x/tools/go/analysis/unitchecker.run.func5.1()
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/analysis/unitchecker/unitchecker.go:355 +0x82e
sync.(*Once).doSlow(0x0?, 0x0?)
        /Users/shota/.goenv/versions/1.18.2/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
        /Users/shota/.goenv/versions/1.18.2/src/sync/once.go:59
golang.org/x/tools/go/analysis/unitchecker.run.func5(0x149f380?)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/analysis/unitchecker/unitchecker.go:307 +0x1a5
golang.org/x/tools/go/analysis/unitchecker.run.func6.1(0x0?)
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/analysis/unitchecker/unitchecker.go:367 +0x29
created by golang.org/x/tools/go/analysis/unitchecker.run.func6
        /Users/shota/go/1.18.2/pkg/mod/golang.org/x/tools@v0.1.11-0.20220316014157-77aa08bb151a/go/analysis/unitchecker/unitchecker.go:366 +0x47

Related issues?