golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.78k stars 727 forks source link

gopls: automated issue report (crash) #3378

Closed jonabc closed 1 month ago

jonabc commented 1 month ago

gopls version: v0.15.3/go1.21.7 gopls flags: update flags: proxy extension version: 0.41.4 environment: Visual Studio Code darwin initialization error: undefined issue timestamp: Tue, 07 May 2024 19:38:41 GMT restart history: Tue, 07 May 2024 00:10:49 GMT: activation (enabled: true) Tue, 07 May 2024 19:01:21 GMT: manual (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

Adding a type argument to a go function caused the go language server to crash. Minimal reproduction in this gist, using github.com/jonabc/channels@v0.4.1.

panic: instantiated ident not found

goroutine 4498 [running]:
go/types.(*Checker).handleBailout(0x14002fee1e0, 0x1400680f838)
      check.go:336  0x9c
panic({0x1030eb880%3F, 0x103260b40%3F})
      panic.go:914  0x218
go/types.instantiatedIdent(...)
      check.go:594
go/types.(*Checker).recordInstance(0x1400441db60%3F, {0x1032693d0%3F, 0x14003254d40%3F}, {0x140066720b0%3F, 0x140066720b0%3F, 0x1%3F}, {0x1032662c8%3F, 0x140011a5300%3F})
      check.go:570  0x1e4
go/types.(*Checker).instantiateSignature(0x14002fee1e0, 0x8e26, {0x1032693d0, 0x14003254d40}, 0x140011a5180, {0x140066720b0, 0x1, 0x1}, {0x0, 0x0, ...})
      call.go:153  0x244
go/types.(*Checker).arguments(0x14002fee1e0, 0x14003254dc0, 0x14003091140, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x14006648810%3F, ...}, ...)
      call.go:643  0x10bc
go/types.(*Checker).callExpr(0x14002fee1e0, 0x140011a4d80, 0x14003254dc0)
      call.go:302  0x6a4
go/types.(*Checker).exprInternal(0x14002fee1e0, {0x0, 0x0}, 0x140011a4d80, {0x1032693d0, 0x14003254dc0%3F}, {0x0%3F, 0x0%3F})
      expr.go:1359  0x12e0
go/types.(*Checker).rawExpr(0x14002fee1e0, {0x0, 0x0}, 0x140011a4d80, {0x1032693d0%3F, 0x14003254dc0%3F}, {0x0%3F, 0x0%3F}, 0x0)
      expr.go:965  0x134
go/types.(*Checker).multiExpr(0x40%3F, {0x1032693d0%3F, 0x14003254dc0}, 0x0)
      expr.go:1517  0x68
go/types.(*Checker).initVars(0x14004eba678%3F, {0x140045284c0%3F, 0x2, 0x2}, {0x14002effe20%3F, 0x1, 0x1}, {0x103269520, 0x14003247700})
      assignments.go:398  0x100
go/types.(*Checker).stmt(0x14002fee1e0, 0x0, {0x103269520%3F, 0x14003247700%3F})
      stmt.go:527  0xfd8
go/types.(*Checker).stmtList(0x12aaf1670%3F, 0x0, {0x14002effe30%3F, 0x14000072900%3F, 0x140060d8af8%3F})
      stmt.go:124  0x88
go/types.(*Checker).funcBody(0x14002fee1e0, 0x1400664e0c0, {0x1400021af90%3F, 0x14002fee1e0%3F}, 0x14000f5b640, 0x140032498c0, {0x0, 0x0})
      stmt.go:44  0x244
go/types.(*Checker).funcDecl.func1()
      decl.go:826  0x44
go/types.(*Checker).processDelayed(0x14002fee1e0, 0x0)
      check.go:439  0x12c
go/types.(*Checker).checkFiles(0x14002fee1e0, {0x14000f5a980, 0x6, 0x8})
      check.go:383  0x1fc
go/types.(*Checker).Files(...)
      check.go:341
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0x140066b3b00, {0x10326ace8, 0x140045d20c0}, 0x14004022a20)
      check.go:1532  0x850
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0x140066b3b00, {0x10326ace8%3F, 0x140045d20c0}, 0x140001d2fc0%3F, {0x14000603740, 0x30})
      check.go:563  0x55c
golang.org/x/tools/gopls/internal/cache.(*Snapshot).forEachPackageInternal.func2()
      check.go:414  0x34
golang.org/x/sync/errgroup.(*Group).Go.func1()
      errgroup.go:78  0x58
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 2914
      errgroup.go:75  0x98
gopls stats -anon gopls stats -anon failed after 668 ms. Please check if gopls is killed by OS.
suzmue commented 1 month ago

This appears to be golang/go#63933, which points to a bug in go/types. Upgrading go to 1.22 should fix this error.