-
-
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
go-critic/ruleguard: unreachable #3136
Comments
Do you have the output of go-critic as a binary? |
Here it is: ➜ di git:(feature/golangci-lint-gocritic) go install -v github.com/go-critic/go-critic/cmd/gocritic@v0.6.4
➜ di git:(feature/golangci-lint-gocritic) gocritic check -v -enableAll ./...
debug: appendAssign is enabled
debug: appendCombine is enabled
debug: argOrder is enabled
debug: assignOp is enabled
debug: badCall is enabled
debug: badCond is enabled
debug: badLock is enabled
debug: badRegexp is enabled
debug: badSorting is enabled
debug: boolExprSimplify is enabled
debug: builtinShadow is enabled
debug: builtinShadowDecl is enabled
debug: captLocal is enabled
debug: caseOrder is enabled
debug: codegenComment is enabled
debug: commentFormatting is enabled
debug: commentedOutCode is enabled
debug: commentedOutImport is enabled
debug: defaultCaseOrder is enabled
debug: deferInLoop is enabled
debug: deferUnlambda is enabled
debug: deprecatedComment is enabled
debug: docStub is enabled
debug: dupArg is enabled
debug: dupBranchBody is enabled
debug: dupCase is enabled
debug: dupImport is enabled
debug: dupSubExpr is enabled
debug: dynamicFmtString is enabled
debug: elseif is enabled
debug: emptyDecl is enabled
debug: emptyFallthrough is enabled
debug: emptyStringTest is enabled
debug: equalFold is enabled
debug: evalOrder is enabled
debug: exitAfterDefer is enabled
debug: exposedSyncMutex is enabled
debug: externalErrorReassign is enabled
debug: filepathJoin is enabled
debug: flagDeref is enabled
debug: flagName is enabled
debug: hexLiteral is enabled
debug: httpNoBody is enabled
debug: hugeParam is enabled
debug: ifElseChain is enabled
debug: importShadow is enabled
debug: indexAlloc is enabled
debug: initClause is enabled
debug: ioutilDeprecated is enabled
debug: mapKey is enabled
debug: methodExprCall is enabled
debug: nestingReduce is enabled
debug: newDeref is enabled
debug: nilValReturn is enabled
debug: octalLiteral is enabled
debug: offBy1 is enabled
debug: paramTypeCombine is enabled
debug: preferDecodeRune is enabled
debug: preferFilepathJoin is enabled
debug: preferFprint is enabled
debug: preferStringWriter is enabled
debug: preferWriteByte is enabled
debug: ptrToRefParam is enabled
debug: rangeExprCopy is enabled
debug: rangeValCopy is enabled
debug: redundantSprint is enabled
debug: regexpMust is enabled
debug: regexpPattern is enabled
debug: regexpSimplify is enabled
debug: returnAfterHttpError is enabled
debug: ruleguard is enabled
debug: singleCaseSwitch is enabled
debug: sliceClear is enabled
debug: sloppyLen is enabled
debug: sloppyReassign is enabled
debug: sloppyTypeAssert is enabled
debug: sortSlice is enabled
debug: sprintfQuotedString is enabled
debug: sqlQuery is enabled
debug: stringConcatSimplify is enabled
debug: stringXbytes is enabled
debug: stringsCompare is enabled
debug: switchTrue is enabled
debug: syncMapLoadAndDelete is enabled
debug: timeCmpSimplify is enabled
debug: timeExprSimplify is enabled
debug: todoCommentWithoutDetail is enabled
debug: tooManyResultsChecker is enabled
debug: truncateCmp is enabled
debug: typeAssertChain is enabled
debug: typeDefFirst is enabled
debug: typeSwitchVar is enabled
debug: typeUnparen is enabled
debug: underef is enabled
debug: unlabelStmt is enabled
debug: unlambda is enabled
debug: unnamedResult is enabled
debug: unnecessaryBlock is enabled
debug: unnecessaryDefer is enabled
debug: unslice is enabled
debug: valSwap is enabled
debug: weakCond is enabled
debug: whyNoLint is enabled
debug: wrapperFunc is enabled
debug: yodaStyleExpr is enabled
debug: checking "github.com/pierrre/di [github.com/pierrre/di.test]" package (2 files)
panic: unreachable [recovered]
panic: unreachable
goroutine 2037 [running]:
github.com/go-critic/go-critic/framework/lintmain/internal/check.(*program).checkFile.func1.1()
/home/pierre/go/pkg/mod/github.com/go-critic/go-critic@v0.6.4/framework/lintmain/internal/check/check.go:160 +0x11e
panic({0x9b67a0, 0xae4498})
/home/pierre/.gimme/versions/go1.19.src/src/runtime/panic.go:884 +0x212
github.com/quasilyte/go-ruleguard/internal/xtypes.typeIdentical({0xae83a0?, 0xc0004be810?}, {0xae8288?, 0xc000148850?}, 0x0)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/internal/xtypes/xtypes.go:218 +0x687
github.com/quasilyte/go-ruleguard/internal/xtypes.Identical(...)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/internal/xtypes/xtypes.go:57
github.com/quasilyte/go-ruleguard/ruleguard/typematch.(*Pattern).matchIdentical(0xc0009eb270?, 0xc00034e150, 0xc00035e5a0, {0xae83a0?, 0xc0004be810?})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/typematch/typematch.go:439 +0xba
github.com/quasilyte/go-ruleguard/ruleguard/typematch.(*Pattern).MatchIdentical(0xc0005a5498, 0xc00034e150, {0xae83a0, 0xc0004be810})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/typematch/typematch.go:370 +0x15d
github.com/quasilyte/go-ruleguard/ruleguard.makeTypeIsFilter.func2(0xc001eb0ef8)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/filters.go:345 +0x117
github.com/quasilyte/go-ruleguard/ruleguard.makeAndFilter.func1(0xa0c4a0?)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/filters.go:46 +0x2e
github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).handleMatch(0xc001eb0d80, {0xc0003791e0, 0x2d8, 0xc0005a54e8, {0xa66a24, 0x34}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/runner.go:352 +0x130
github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).runRules.func1({{0xae7928, 0xc000128880}, {0xc00301c400, 0x3, 0x8}})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/runner.go:252 +0xc5
github.com/quasilyte/gogrep.(*matcher).MatchNode(0xc0003542e0, 0xc001eb0df0, {0xae7928?, 0xc000128880?}, 0xc0009eb758)
/home/pierre/go/pkg/mod/github.com/quasilyte/gogrep@v0.0.0-20220120141003-628d8b3623b5/match.go:84 +0x4e3
github.com/quasilyte/gogrep.(*Pattern).MatchNode(...)
/home/pierre/go/pkg/mod/github.com/quasilyte/gogrep@v0.0.0-20220120141003-628d8b3623b5/gogrep.go:90
github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).runRules(0xc001eb0d80?, {0xae7928?, 0xc000128880?}, 0x2?)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/runner.go:251 +0x14b
github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).run.func1({0xae7928?, 0xc000128880?}, 0x1?)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/runner.go:166 +0x33
github.com/quasilyte/go-ruleguard/ruleguard.(*astWalker).walk(0xc0009ebc18, {0xae7928?, 0xc000128880?})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ast_walker.go:194 +0x1851
github.com/quasilyte/go-ruleguard/ruleguard.(*astWalker).walkStmtList(0xae7a18?, {0xc000172e00?, 0x9, 0x7f9cf40b9208?})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ast_walker.go:37 +0x85
github.com/quasilyte/go-ruleguard/ruleguard.(*astWalker).walk(0xc0009ebc18, {0xae7a18?, 0xc0000a69c0?})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ast_walker.go:218 +0x181e
github.com/quasilyte/go-ruleguard/ruleguard.(*astWalker).walk(0xc0009ebc18, {0xae7ce8?, 0xc0000a69f0?})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ast_walker.go:360 +0x7d9
github.com/quasilyte/go-ruleguard/ruleguard.(*astWalker).walkDeclList(0xc000083c18?, {0xc000172d00?, 0xf, 0xc000083b98?})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ast_walker.go:43 +0x85
github.com/quasilyte/go-ruleguard/ruleguard.(*astWalker).walk(0xc000083c18, {0xae7c98?, 0xc000040c80?})
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ast_walker.go:367 +0x135e
github.com/quasilyte/go-ruleguard/ruleguard.(*astWalker).Walk(...)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ast_walker.go:20
github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).run(0xc001eb0d80, 0xc000040c80)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/runner.go:165 +0x1c9
github.com/quasilyte/go-ruleguard/ruleguard.(*engine).Run(0x66715e?, 0x60?, 0xc0007fc5ac?, 0x0?)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/engine.go:130 +0x45
github.com/quasilyte/go-ruleguard/ruleguard.(*Engine).Run(...)
/home/pierre/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.17/ruleguard/ruleguard.go:74
github.com/go-critic/go-critic/checkers.runRuleguardEngine(0xc00031dbc8, 0xc000040c80, 0xc00034e740, 0xc0027805b0)
/home/pierre/go/pkg/mod/github.com/go-critic/go-critic@v0.6.4/checkers/ruleguard_checker.go:301 +0xd9
github.com/go-critic/go-critic/checkers.(*embeddedRuleguardChecker).WalkFile(0xc00034ea00, 0xc000112380?)
/home/pierre/go/pkg/mod/github.com/go-critic/go-critic@v0.6.4/checkers/embedded_rules.go:98 +0xea
github.com/go-critic/go-critic/framework/linter.(*Checker).Check(...)
/home/pierre/go/pkg/mod/github.com/go-critic/go-critic@v0.6.4/framework/linter/linter.go:130
github.com/go-critic/go-critic/framework/lintmain/internal/check.(*program).checkFile.func1(0x25, 0xc00031dbc0)
/home/pierre/go/pkg/mod/github.com/go-critic/go-critic@v0.6.4/framework/lintmain/internal/check/check.go:164 +0xc2
created by github.com/go-critic/go-critic/framework/lintmain/internal/check.(*program).checkFile
/home/pierre/go/pkg/mod/github.com/go-critic/go-critic@v0.6.4/framework/lintmain/internal/check/check.go:146 +0xa5 |
So it's a go-critic issue ? 😄 |
yes 😸 |
So it's go-critic/go-critic#1219 |
Sorry, my bad, I thought go-critic was fully functional with generics 😞 |
Sharing some updates go-critic/go-critic#1253 |
For now my quick fix is to disable the |
I think go-critic works better with generics than go-ruleguard. go-ruleguard uses a lot of dark magic and its relationship with the underlying |
Fixes by #3150 |
Welcome
Description of the problem
When I run golangci-lint on a package that contains generic code, the go-critic/ruleguard linter panics with the message "unreachable".
Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
https://github.com/pierrre/di/tree/feature/golangci-lint-gocritic
The text was updated successfully, but these errors were encountered: