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 #3476

Closed c4p741nth closed 1 month ago

c4p741nth 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 win32 initialization error: undefined issue timestamp: Wed, 31 Jul 2024 02:51:01 GMT restart history: Wed, 31 Jul 2024 02:28:43 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: C:/Program   stmt.go:932: assertion failed

goroutine 3975 [running]:
go/types.(*Checker).handleBailout(0xc000185200, 0xc003f3d898)
    C:/Program   check.go:367  0x88
panic({0x1a6b920%3F, 0xc001e2b6a0%3F})
    C:/Program   panic.go:770  0x132
go/types.assert(0x0%3F)
    C:/Program   errors.go:28  0x54
go/types.(*Checker).rangeStmt(0xc000185200, 0x3, 0xc000092f60)
    C:/Program   stmt.go:932  0xe70
go/types.(*Checker).stmt(0xc000185200, 0x3, {0x1eedf80, 0xc000092f60})
    C:/Program   stmt.go:827  0xab9
go/types.(*Checker).stmtList(0xc000185200, 0x3, {0xc004603380%3F, 0x1be9d66%3F, 0x5%3F})
    C:/Program   stmt.go:121  0x85
go/types.(*Checker).stmt(0xc000185200, 0x3, {0x1eedf20, 0xc000b83950})
    C:/Program   stmt.go:562  0x20f2
go/types.(*Checker).rangeStmt(0xc000185200, 0x3, 0xc000092fc0)
    C:/Program   stmt.go:993  0x74d
go/types.(*Checker).stmt(0xc000185200, 0x0, {0x1eedf80, 0xc000092fc0})
    C:/Program   stmt.go:827  0xab9
go/types.(*Checker).stmtList(0xc000185200, 0x0, {0xc000a89f00%3F, 0x120%3F, 0xc000500808%3F})
    C:/Program   stmt.go:121  0x85
go/types.(*Checker).funcBody(0xc000185200, 0x1eea398%3F, {0xc000690010%3F, 0xc001e2ae20%3F}, 0xc0000a18c0, 0xc000b83a10, {0x0%3F, 0x0%3F})
    C:/Program   stmt.go:41  0x331
go/types.(*Checker).funcDecl.func1()
    C:/Program   decl.go:852  0x3a
go/types.(*Checker).processDelayed(0xc000185200, 0x0)
    C:/Program   check.go:467  0x162
go/types.(*Checker).checkFiles(0xc000185200, {0xc001308aa0, 0x3, 0x4})
    C:/Program   check.go:411  0x1cc
go/types.(*Checker).Files(...)
    C:/Program   check.go:372
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0xc0021fec60, {0x1eef228, 0xc001d9d080}, 0xc005444000)
      check.go:1543  0xa25
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0xc0021fec60, {0x1eef228, 0xc001d9d080}, 0x0, {0xc000037a80, 0x1d})
      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 145
      errgroup.go:75  0x96
gopls stats -anon { "DirStats": { "Files": 1116, "TestdataFiles": 0, "GoFiles": 192, "ModFiles": 1, "Dirs": 335 }, "GOARCH": "amd64", "GOOS": "windows", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.5", "GoplsVersion": "v0.16.1", "InitialWorkspaceLoadDuration": "2.0497819s", "MemStats": { "HeapAlloc": 53204168, "HeapInUse": 89612288, "TotalAlloc": 897736944 }, "WorkspaceStats": { "Files": { "Total": 2886, "Largest": 1351282, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.5", "AllPackages": { "Packages": 623, "LargestPackage": 148, "CompiledGoFiles": 2890, "Modules": 97 }, "WorkspacePackages": { "Packages": 57, "LargestPackage": 17, "CompiledGoFiles": 198, "Modules": 1 }, "Diagnostics": 1 } ] } }
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)

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

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