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

SA4023: nilness check panics with 'unhandled type *ir.SliceToArray' #1529

Open
tdakkota opened this issue Apr 25, 2024 · 0 comments
Open

SA4023: nilness check panics with 'unhandled type *ir.SliceToArray' #1529

tdakkota opened this issue Apr 25, 2024 · 0 comments
Labels
bug needs-triage Newly filed issue that needs triage

Comments

@tdakkota
Copy link
Contributor

tdakkota commented Apr 25, 2024

The output of 'staticcheck -debug.version'

staticcheck 2023.1.7 (v0.4.7)

Compiled with Go version: go1.22.2
Main module:
        honnef.co/go/tools@v0.4.7 (sum: h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=)
Dependencies:
        github.com/BurntSushi/toml@v1.2.1 (sum: h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=)
        golang.org/x/exp/typeparams@v0.0.0-20221208152030-732eee02a75a (sum: h1:Jw5wfR+h9mnIYH+OtGT2im5wV1YGGDora5vTv/aa5bE=)
        golang.org/x/mod@v0.12.0 (sum: h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=)
        golang.org/x/sys@v0.11.0 (sum: h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=)
        golang.org/x/tools@v0.12.1-0.20230825192346-2191a27a6dc5 (sum: h1:Vk4mysSz+GqQK2eqgWbo4zEO89wkeAjJiFIr9bpqa8k=)

The output of 'go version'

go version go1.22.2 linux/amd64

Exactly which command you ran

staticcheck -checks SA4107 ./reproducer

Output of the command and what's wrong with the output

panic: internal error: unhandled type *ir.SliceToArray

goroutine 277 [running]:
honnef.co/go/tools/analysis/facts/nilness.impl.func1({0xa3a518, 0xc0002d63f0})
        /home/tdakkota/go/pkg/mod/honnef.co/go/tools@v0.4.7/analysis/facts/nilness/nilness.go:239 +0x8a5
honnef.co/go/tools/analysis/facts/nilness.impl(0xc0005ccf70, 0xc000226140, 0xc000464e08)
        /home/tdakkota/go/pkg/mod/honnef.co/go/tools@v0.4.7/analysis/facts/nilness/nilness.go:246 +0x348
honnef.co/go/tools/analysis/facts/nilness.run(0xc0005ccf70)
        /home/tdakkota/go/pkg/mod/honnef.co/go/tools@v0.4.7/analysis/facts/nilness/nilness.go:66 +0x125
honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0xc0000e73b0, {0xa37b78?, 0xc000516500})
        /home/tdakkota/go/pkg/mod/honnef.co/go/tools@v0.4.7/lintcmd/runner/runner.go:992 +0x71b
honnef.co/go/tools/lintcmd/runner.genericHandle({0xa37b78, 0xc000516500}, {0xa37b78?, 0xc0004b43c0?}, 0xc0000d1800, 0xc00038f370, 0xc000202ba0)
        /home/tdakkota/go/pkg/mod/honnef.co/go/tools@v0.4.7/lintcmd/runner/runner.go:817 +0x11f
created by honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers in goroutine 163
        /home/tdakkota/go/pkg/mod/honnef.co/go/tools@v0.4.7/lintcmd/runner/runner.go:1061 +0x6a6

Where we can read the code you're running Staticcheck on

Reproducer:

package reproducer

func fillRandom[S ~[8]byte | ~[16]byte]() (s S) {
	var buf []byte
	return (S)(buf)
}

Issue also could be reproduced with golangci-lint v1.57.2
Pretty similar to #1397.

@tdakkota tdakkota added bug needs-triage Newly filed issue that needs triage labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Newly filed issue that needs triage
Projects
None yet
Development

No branches or pull requests

1 participant