golang / vscode-go

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

gopls: automated issue report (crash) - assertion failure in range statement checking logic #3475

Closed duguying closed 1 month ago

duguying commented 1 month ago

gopls version: v0.16.1/go1.22.5 gopls flags: update flags: proxy extension version: 0.42.0 environment: Visual Studio Code linux initialization error: undefined issue timestamp: Tue, 30 Jul 2024 03:21:26 GMT restart history: Mon, 29 Jul 2024 01:59:04 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic:   stmt.go:932: assertion failed

goroutine 6506 [running]:
go/types.(*Checker).handleBailout(0xc0005ad400, 0xc00df0b898)
      check.go:367  0x88
panic({0xe9b560%3F, 0xc00e134470%3F})
      panic.go:770  0x132
go/types.assert(0x0%3F)
      errors.go:28  0x54
go/types.(*Checker).rangeStmt(0xc0005ad400, 0x3, 0xc00819d500)
      stmt.go:932  0xe70
go/types.(*Checker).stmt(0xc0005ad400, 0x0, {0x1319688, 0xc00819d500})
      stmt.go:827  0xab9
go/types.(*Checker).stmtList(0xc0005ad400, 0x0, {0xc008236200%3F, 0x0%3F, 0x45921e%3F})
      stmt.go:121  0x85
go/types.(*Checker).funcBody(0xc0005ad400, 0x1316d08%3F, {0xc000e7ba80%3F, 0xc000146380%3F}, 0xc006acfb00, 0xc008238870, {0x0%3F, 0x0%3F})
      stmt.go:41  0x331
go/types.(*Checker).funcDecl.func1()
      decl.go:852  0x3a
go/types.(*Checker).processDelayed(0xc0005ad400, 0x0)
      check.go:467  0x162
go/types.(*Checker).checkFiles(0xc0005ad400, {0xc00d0fe008, 0x4b, 0x8f})
      check.go:411  0x1cc
go/types.(*Checker).Files(...)
      check.go:372
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0xc007bc2780, {0x131aa28, 0xc00827b0b0}, 0xc00125e000)
      check.go:1543  0xa25
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0xc007bc2780, {0x131aa28, 0xc00827b0b0}, 0x0, {0xc00099f830, 0x30})
      check.go:568  0x5e5
golang.org/x/tools/gopls/internal/cache.(*Snapshot).forEachPackageInternal.func2()
      check.go:418  0x2b
golang.org/x/sync/errgroup.(*Group).Go.func1()
      errgroup.go:78  0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 134
      errgroup.go:75  0x96
gopls stats -anon gopls stats -anon failed after 1912 ms. Please check if gopls is killed by OS.
OPTIONAL: If you would like to share more information, you can attach your complete gopls logs. NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE. DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.
hyangah commented 1 month ago

Dup of https://github.com/golang/go/issues/68334

Looks like the fix will be available in go1.22.6 and go1.23.0. (not released yet)

@duguying If you build the gopls with go1.23rc2, does it fix the problem?

GOTOOLCHAIN=go1.23rc2 go install golang.org/x/tools/gopls@latest

duguying commented 1 month ago

i'll try it today.