golang / vscode-go

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

gopls: automated issue report (crash) #3446

Closed andrea3bianchi closed 1 month ago

andrea3bianchi commented 1 month ago

gopls version: v0.16.1/go1.22.5 gopls flags: update flags: proxy extension version: 0.41.4 environment: Visual Studio Code darwin initialization error: undefined issue timestamp: Wed, 10 Jul 2024 12:55:04 GMT restart history: Tue, 09 Jul 2024 21:23:17 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

Was writing down some helpers using reflect.Type, had hit autocomplete on a (wrong) copilot suggestion for the line for _, field := range paramType.NumField() { where paramType is of reflect.Type type

panic:   stmt.go:932: assertion failed

goroutine 5791 [running]:
go/types.(*Checker).handleBailout(0x1400733a400, 0x14007c7d878)
      check.go:367  0x9c
panic({0x101b9b3a0%3F, 0x14007c64f30%3F})
      panic.go:770  0x124
go/types.assert(0x0%3F)
      errors.go:28  0x60
go/types.(*Checker).rangeStmt(0x1400733a400, 0x3, 0x140005aac00)
      stmt.go:932  0xb58
go/types.(*Checker).stmt(0x1400733a400, 0x0, {0x101d24e80, 0x140005aac00})
      stmt.go:827  0x874
go/types.(*Checker).stmtList(0x1400733a400, 0x0, {0x14005ee5300%3F, 0x0%3F, 0x1%3F})
      stmt.go:121  0x88
go/types.(*Checker).funcBody(0x1400733a400, 0x101d22588%3F, {0x14000749130%3F, 0x14005940070%3F}, 0x14004a14a40, 0x14005bf5200, {0x0%3F, 0x0%3F})
      stmt.go:41  0x21c
go/types.(*Checker).funcDecl.func1()
      decl.go:852  0x44
go/types.(*Checker).processDelayed(0x1400733a400, 0x0)
      check.go:467  0x12c
go/types.(*Checker).checkFiles(0x1400733a400, {0x14007c64c10, 0x2, 0x2})
      check.go:411  0x188
go/types.(*Checker).Files(...)
      check.go:372
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0x140078d83c0, {0x101d26168, 0x14006403a70}, 0x140013acc60)
      check.go:1543  0x788
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0x140078d83c0, {0x101d26168, 0x14006403a70}, 0x0, {0x1400106f3b0, 0x45})
      check.go:568  0x534
golang.org/x/tools/gopls/internal/cache.(*Snapshot).forEachPackageInternal.func2()
      check.go:418  0x34
golang.org/x/sync/errgroup.(*Group).Go.func1()
      errgroup.go:78  0x58
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 133
      errgroup.go:75  0x98
gopls stats -anon { "DirStats": { "Files": 13733, "TestdataFiles": 0, "GoFiles": 1619, "ModFiles": 2, "Dirs": 1694 }, "GOARCH": "arm64", "GOOS": "darwin", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.5", "GoplsVersion": "v0.16.1", "InitialWorkspaceLoadDuration": "1.627212417s", "MemStats": { "HeapAlloc": 106721368, "HeapInUse": 191602688, "TotalAlloc": 1306128816 }, "WorkspaceStats": { "Files": { "Total": 5224, "Largest": 1047179, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.5", "AllPackages": { "Packages": 1344, "LargestPackage": 155, "CompiledGoFiles": 5223, "Modules": 158 }, "WorkspacePackages": { "Packages": 453, "LargestPackage": 21, "CompiledGoFiles": 1095, "Modules": 1 }, "Diagnostics": 10 } ] } }

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.

findleyr commented 1 month ago

Thank you for the report. Duplicate of golang/go#68334.

This is a regression in Go 1.22.5.