Skip to content

go/types: assertion failure in recent range statement checking logic #68334

@lmorg

Description

@lmorg

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: Fri, 05 Jul 2024 22:28:48 GMT
restart history:
Fri, 05 Jul 2024 21:41:59 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic:   stmt.go:932: assertion failed

goroutine 3607 [running]:
go/types.(*Checker).handleBailout(0x1400113ca00, 0x14005649878)
	  check.go:367  0x9c
panic({0x102d833a0%3F, 0x14000aee0e0%3F})
	  panic.go:770  0x124
go/types.assert(0x0%3F)
	  errors.go:28  0x60
go/types.(*Checker).rangeStmt(0x1400113ca00, 0x3, 0x140030696e0)
	  stmt.go:932  0xb58
go/types.(*Checker).stmt(0x1400113ca00, 0x3, {0x102f0ce80, 0x140030696e0})
	  stmt.go:827  0x874
go/types.(*Checker).stmtList(0x1400113ca00, 0x3, {0x140030c0480%3F, 0x102a04115%3F, 0x5%3F})
	  stmt.go:121  0x88
go/types.(*Checker).stmt(0x1400113ca00, 0x3, {0x102f0ce20, 0x140030b0fc0})
	  stmt.go:562  0x1974
go/types.(*Checker).rangeStmt(0x1400113ca00, 0x3, 0x14003069920)
	  stmt.go:993  0x570
go/types.(*Checker).stmt(0x1400113ca00, 0x0, {0x102f0ce80, 0x14003069920})
	  stmt.go:827  0x874
go/types.(*Checker).stmtList(0x1400113ca00, 0x0, {0x1400303f580%3F, 0x1020ec4e8%3F, 0x14005648668%3F})
	  stmt.go:121  0x88
go/types.(*Checker).funcBody(0x1400113ca00, 0x102f0a588%3F, {0x102a364cd%3F, 0x140000d4380%3F}, 0x14002ea4600, 0x140030b1050, {0x0%3F, 0x0%3F})
	  stmt.go:41  0x21c
go/types.(*Checker).exprInternal.func1()
	  expr.go:1089  0x44
go/types.(*Checker).processDelayed(0x1400113ca00, 0x92)
	  check.go:467  0x12c
go/types.(*Checker).stmt(0x1400113ca00, 0x0, {0x102f0cd00, 0x140030b4960})
	  stmt.go:832  0x1db0
go/types.(*Checker).stmtList(0x1400113ca00, 0x0, {0x140007e5d00%3F, 0x0%3F, 0x140056496d8%3F})
	  stmt.go:121  0x88
go/types.(*Checker).funcBody(0x1400113ca00, 0x102f0a588%3F, {0x140007843a0%3F, 0x140000d4380%3F}, 0x140028ff6c0, 0x140030b1080, {0x0%3F, 0x0%3F})
	  stmt.go:41  0x21c
go/types.(*Checker).funcDecl.func1()
	  decl.go:852  0x44
go/types.(*Checker).processDelayed(0x1400113ca00, 0x0)
	  check.go:467  0x12c
go/types.(*Checker).checkFiles(0x1400113ca00, {0x14003bb7300, 0xa, 0x10})
	  check.go:411  0x188
go/types.(*Checker).Files(...)
	  check.go:372
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0x1400546e8a0, {0x102f0e168, 0x14003234270}, 0x14003683c20)
	  check.go:1543  0x788
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0x1400546e8a0, {0x102f0e168, 0x14003234270}, 0x0, {0x14000ab48d0, 0x2d})
	  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 151
	  errgroup.go:75  0x98
gopls stats -anon { "DirStats": { "Files": 1984, "TestdataFiles": 5, "GoFiles": 1083, "ModFiles": 1, "Dirs": 235 }, "GOARCH": "arm64", "GOOS": "darwin", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.5", "GoplsVersion": "v0.16.1", "InitialWorkspaceLoadDuration": "1.169338542s", "MemStats": { "HeapAlloc": 60239376, "HeapInUse": 106414080, "TotalAlloc": 703540872 }, "WorkspaceStats": { "Files": { "Total": 2250, "Largest": 5748466, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.5", "AllPackages": { "Packages": 742, "LargestPackage": 155, "CompiledGoFiles": 3962, "Modules": 26 }, "WorkspacePackages": { "Packages": 271, "LargestPackage": 63, "CompiledGoFiles": 1417, "Modules": 1 }, "Diagnostics": 0 } ] } }

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.

<OPTIONAL: ATTACH LOGS HERE>

Metadata

Metadata

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions