-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Panic on a valid go1.17 program with default configuration #2292
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
FWIW
|
I can also reproduce this with the latest commit.
|
bug.gopackage bug
import "sync/atomic"
type Secret [32]byte
func SecretFromBytes(buf []byte) (*Secret, bool) {
if len(buf) != len(Secret{}) {
return nil, false
}
return (*Secret)(buf), true
}
func foo() {
_ = atomic.Value{}
} .golangci.ymllinters:
enable-all: true
disable:
- staticcheck
- stylecheck
- gosimple
- unused go.modmodule github.com/golangci/sandbox
go 1.17
require github.com/stretchr/testify v1.7.0
require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
) run with a build of the current HEAD of golangci-lint (go1.17.2)$ ./golangci-lint run
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive.
WARN [runner] The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.
WARN [runner] The linter 'maligned' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner. Replaced by govet 'fieldalignment'.
WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner. Replaced by exportloopref.
bug.go:14:6: `foo` is unused (deadcode)
func foo() {
^
bug.go:11:2: return statements should not be cuddled if block has more than two lines (wsl)
return (*Secret)(buf), true
^
bug_test.go:44:3: expressions should not be cuddled with blocks (wsl)
assert.Equal(t, tc.Secret, secret)
^
bug_test.go:10:1: Function TestSecretFromBytes missing the call to method parallel (paralleltest)
func TestSecretFromBytes(t *testing.T) {
^
bug_test.go:1:9: package should be `bug_test` instead of `bug` (testpackage)
package bug
^
bug_test.go:37:6: variable name 'tc' is too short for the scope of its usage (varnamelen)
for _, tc := range testCases {
^
run with a build of the current HEAD of staticcheck (go1.17.2)$ ./staticcheck .
panic: in github.com/golangci/sandbox.SecretFromBytes: cannot convert Load <[]byte> t0 ([]byte) to *github.com/golangci/sandbox.Secret
goroutine 165 [running]:
honnef.co/go/tools/go/ir.emitConv(0xc0008da480, {0x96b548, 0xc000561620}, {0x95c420, 0xc000620b40}, {0x95bb60, 0xc000286300})
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/emit.go:261 +0xb25
honnef.co/go/tools/go/ir.(*builder).expr0(0xc0002e3b00, 0xc0008da480, {0x95d720, 0xc000286300}, {0x7, {0x95c420, 0xc000620b40}, {0x0, 0x0}})
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:544 +0xa77
honnef.co/go/tools/go/ir.(*builder).expr(0xc0008da480, 0xc0008da480, {0x95d720, 0xc000286300})
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:500 +0x1db
honnef.co/go/tools/go/ir.(*builder).stmt(0x889c40, 0xc0008da480, {0x95dc30, 0xc0006be360})
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:2142 +0x1ab8
honnef.co/go/tools/go/ir.(*builder).stmtList(0x4, 0xc0005612c0, {0xc0006be380, 0x2, 0x20})
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:752 +0x67
honnef.co/go/tools/go/ir.(*builder).stmt(0xc0008da480, 0xc0008da480, {0x95d6c0, 0xc00039a630})
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:2189 +0xd05
honnef.co/go/tools/go/ir.(*builder).buildFunction(0xc0008e7b00, 0xc0008da480)
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:2301 +0x44a
honnef.co/go/tools/go/ir.(*builder).buildFuncDecl(0xc0003982a0, 0xc0006863f0, 0xc00039a660)
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:2339 +0x195
honnef.co/go/tools/go/ir.(*Package).build(0xc0006863f0)
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:2445 +0xc52
sync.(*Once).doSlow(0xc00013a2c0, 0xc0006baa00)
/home/ldez/.gvm/gos/go1.17.2/src/sync/once.go:68 +0xd2
sync.(*Once).Do(...)
/home/ldez/.gvm/gos/go1.17.2/src/sync/once.go:59
honnef.co/go/tools/go/ir.(*Package).Build(...)
/home/ldez/sources/go/src/honnef.co/go/tools/go/ir/builder.go:2363
honnef.co/go/tools/internal/passes/buildir.run(0xc00011cdd0)
/home/ldez/sources/go/src/honnef.co/go/tools/internal/passes/buildir/buildir.go:86 +0x308
honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0xc0006e07e0, {0x965bf8, 0xc000156960})
/home/ldez/sources/go/src/honnef.co/go/tools/lintcmd/runner/runner.go:937 +0x614
honnef.co/go/tools/lintcmd/runner.genericHandle({0x965bf8, 0xc000156960}, {0x965bf8, 0xc0001560a0}, 0x0, 0xc0003880b8, 0xc000621d50)
/home/ldez/sources/go/src/honnef.co/go/tools/lintcmd/runner/runner.go:762 +0x102
created by honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers
/home/ldez/sources/go/src/honnef.co/go/tools/lintcmd/runner/runner.go:1003 +0x725
staticcheck is a binary and a set of rules, those rules are grouped in "category": The problem comes from staticcheck itself, so an issue must open of the staticcheck repo. Maybe @dominikh already has a fix. |
No, this is not yet fixed. However, I can see why it happens, and an outstanding PR (dominikh/go-tools#1081) contains a fix for it. Fix incoming soon. |
This should be fixed on master now. I'll publish a new patch release on Monday. |
Closed by #2370 |
Welcome
Description of the problem
Running
golangci-lint run
panics on a valid Go 1.17 program.Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
go.mod
go.sum
bug.go
bug_test.go
The text was updated successfully, but these errors were encountered: