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

Staticcheck panics "unreachable" when calling a function in a slice wrapped in parens #1400

Closed
dakota-doordash opened this issue Apr 28, 2023 · 1 comment
Labels

Comments

@dakota-doordash
Copy link

dakota-doordash commented Apr 28, 2023

Staticcheck version:
staticcheck 2023.1.3 (v0.4.3)

Staticcheck debug version:

staticcheck 2023.1.3 (v0.4.3)

Compiled with Go version: go1.20
Main module:
       honnef.co/go/tools@v0.4.3 (sum: h1:o/n5/K5gXqk8Gozvs2cnL0F2S1/g1vcGCAx2vETjITw=)
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.7.0 (sum: h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=)
       golang.org/x/sys@v0.3.0 (sum: h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=)
       golang.org/x/tools@v0.4.1-0.20221208213631-3f74d914ae6d (sum: h1:9ZNWAi4CYhNv60mXGgAncgq7SGc5qa7C8VZV8Tg7Ggs=)

Go version:
go version go1.20 darwin/arm64

Command:
staticcheck ./...

Output:

panic: unreachable

goroutine 780 [running]:
honnef.co/go/tools/pattern.Symbol.Match({{0x104817358?, 0x104aeb0f8?}}, 0x1400226ac00, {0x1047a2600, 0x140000fb710})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/pattern/match.go:577 +0x698
honnef.co/go/tools/pattern.match(0x1400226ac00, {0x1047c3ae0?, 0x1400006fea0?}, {0x1047a2600?, 0x140000fb710?})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/pattern/match.go:194 +0xccc
honnef.co/go/tools/pattern.Binding.Match({{0x10468bee7, 0x3}, {0x104817ad8, 0x1400006fea0}, 0x0}, 0x1400226ac00, {0x1047a2600, 0x140000fb710})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/pattern/match.go:453 +0x108
honnef.co/go/tools/pattern.match(0x1400226ac00, {0x1047e4340?, 0x140000953b0?}, {0x1047a2600?, 0x140000fb710?})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/pattern/match.go:194 +0xccc
honnef.co/go/tools/pattern.matchNodeAST(0x14001b15998?, {0x104817498?, 0x1400008f9a0}, {0x1047a1b80?, 0x14000d90a80?})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/pattern/match.go:369 +0x6a0
honnef.co/go/tools/pattern.match(0x1400226ac00, {0x1047c8b00?, 0x1400008f9a0?}, {0x1047a1b80?, 0x14000d90a80?})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/pattern/match.go:199 +0xca8
honnef.co/go/tools/pattern.(*Matcher).Match(0x1400226ac00, {{0x104817498, 0x1400008f9a0}, 0x140000953e0, {0x14000092f10, 0x1, 0x1}}, {0x104816458?, 0x14000d90a80})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/pattern/match.go:129 +0x12c
honnef.co/go/tools/analysis/code.Match(...)
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/analysis/code/visit.go:33
honnef.co/go/tools/staticcheck.CheckNilContext.func1({0x104816458?, 0x14000d90a80?})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/staticcheck/lint.go:2341 +0xd0
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0x140029160f0, {0x140000dc5e8?, 0x1?, 0x1042ec040?}, 0x14000e2fdf8)
        <redacted>/go/pkg/mod/golang.org/x/tools@v0.4.1-0.20221208213631-3f74d914ae6d/go/ast/inspector/inspector.go:77 +0x9c
honnef.co/go/tools/analysis/code.Preorder(...)
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/analysis/code/visit.go:16
honnef.co/go/tools/staticcheck.CheckNilContext(0x1400244e1e0)
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/staticcheck/lint.go:2367 +0x354
honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0x140018aa0f0, {0x1048195f0?, 0x140000bd9a0})
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/lintcmd/runner/runner.go:992 +0x660
honnef.co/go/tools/lintcmd/runner.genericHandle({0x1048195f0?, 0x140000bd9a0}, {0x1048195f0?, 0x1400147a460?}, 0x0?, 0x140004239f0, 0x14002912390)
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/lintcmd/runner/runner.go:817 +0x11c
created by honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers
        <redacted>/go/pkg/mod/honnef.co/go/tools@v0.4.3/lintcmd/runner/runner.go:1061 +0x5bc

Sample code:

func main() {
	foo := []func(){
		func() {},
	}
	(foo)[0]()
}

AST:

     0  *ast.IndexExpr {
     1  .  X: *ast.ParenExpr {
     2  .  .  Lparen: 41566427
     3  .  .  X: *ast.Ident {
     4  .  .  .  NamePos: 41566428
     5  .  .  .  Name: "foo"
     6  .  .  .  Obj: nil
     7  .  .  }
     8  .  .  Rparen: 41566431
     9  .  }
    10  .  Lbrack: 41566432
    11  .  Index: *ast.BasicLit {
    12  .  .  ValuePos: 41566433
    13  .  .  Kind: INT
    14  .  .  Value: "0"
    15  .  }
    16  .  Rbrack: 41566434
    17  }
@dakota-doordash dakota-doordash added bug needs-triage Newly filed issue that needs triage labels Apr 28, 2023
@dominikh dominikh removed the needs-triage Newly filed issue that needs triage label Apr 28, 2023
@dominikh
Copy link
Owner

Fixed, thanks.

dominikh added a commit that referenced this issue Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants