Skip to content

go/types, types2: panic with "unexpected *types.Tuple" in isParameterized #59890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
findleyr opened this issue Apr 28, 2023 · 5 comments
Closed
Assignees
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@findleyr
Copy link
Member

New panic at tip. Does not reproduce in 1.20.

Repro:

package p

var _ = append(f()())

func f[T any]() (_, _, int) {
	panic("not implemented")
}

Output:

panic: unexpected *types.Tuple [recovered]
	panic: unexpected *types.Tuple [recovered]
	panic: unexpected *types.Tuple

goroutine 6 [running]:
testing.tRunner.func1.2({0x690640, 0xc00002e9b0})
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1548 +0x39f
panic({0x690640?, 0xc00002e9b0?})
	/usr/local/google/home/rfindley/src/go/src/runtime/panic.go:914 +0x21f
go/types.(*Checker).handleBailout(0xc000162000, 0xc00016b8a8)
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:335 +0x88
panic({0x690640?, 0xc00002e9b0?})
	/usr/local/google/home/rfindley/src/go/src/runtime/panic.go:914 +0x21f
go/types.(*tpWalker).isParameterized(0xc000169808, {0x7581c8, 0xc0000102a0})
	/usr/local/google/home/rfindley/src/go/src/go/types/infer.go:546 +0x446
go/types.isParameterized(...)
	/usr/local/google/home/rfindley/src/go/src/go/types/infer.go:469
go/types.(*Checker).callExpr(0xc000162000, 0xc000015200, 0xc000014f00)
	/usr/local/google/home/rfindley/src/go/src/go/types/call.go:339 +0xb29
go/types.(*Checker).exprInternal(0xc000162000, {0x0, 0x0}, 0xc000015200, {0x7595f0, 0xc000014f00?}, {0x0?, 0x0?})
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1648 +0x1425
go/types.(*Checker).rawExpr(0xc000162000, {0x0, 0x0}, 0xc000015200, {0x7595f0?, 0xc000014f00?}, {0x0?, 0x0?}, 0x1)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1254 +0x1ac
go/types.(*Checker).exprOrType(0x0?, 0xc000160668?, {0x7595f0?, 0xc000014f00?}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1847 +0x45
go/types.(*Checker).callExpr(0xc000162000, 0xc000015200, 0xc000014f40)
	/usr/local/google/home/rfindley/src/go/src/go/types/call.go:192 +0x2cd
go/types.(*Checker).exprInternal(0xc000162000, {0x0, 0x0}, 0xc000015200, {0x7595f0, 0xc000014f40?}, {0x0?, 0x0?})
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1648 +0x1425
go/types.(*Checker).rawExpr(0xc000162000, {0x0, 0x0}, 0xc000015200, {0x7595f0?, 0xc000014f40?}, {0x0?, 0x0?}, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1254 +0x1ac
go/types.(*Checker).multiExpr(0x7579e0?, {0x7595f0?, 0xc000014f40}, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1806 +0x85
go/types.(*Checker).exprList(0x0?, {0xc00002e790?, 0x0?, 0xc000014f40?})
	/usr/local/google/home/rfindley/src/go/src/go/types/call.go:351 +0x6c
go/types.(*Checker).builtin(0xc000162000, 0xc0000151c0, 0xc000014f80, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/builtins.go:49 +0x26c
go/types.(*Checker).callExpr(0xc000162000, 0xc0000151c0, 0xc000014f80)
	/usr/local/google/home/rfindley/src/go/src/go/types/call.go:238 +0xfd9
go/types.(*Checker).exprInternal(0xc000162000, {0x0, 0x0}, 0xc0000151c0, {0x7595f0, 0xc000014f80?}, {0x0?, 0x0?})
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1648 +0x1425
go/types.(*Checker).rawExpr(0xc000162000, {0x0, 0x0}, 0xc0000151c0, {0x7595f0?, 0xc000014f80?}, {0x0?, 0x0?}, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1254 +0x1ac
go/types.(*Checker).expr(0x40384b?, {0x0?, 0x0?}, 0x6ca3c0?, {0x7595f0?, 0xc000014f80?})
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1787 +0x45
go/types.(*Checker).varDecl(0x69d820?, 0xc000030780, {0xc0000560e0?, 0x1, 0x1}, {0x0, 0x0}, {0x7595f0, 0xc000014f80})
	/usr/local/google/home/rfindley/src/go/src/go/types/decl.go:513 +0x16c
go/types.(*Checker).objDecl(0xc000162000, {0x75b1b8, 0xc000030780}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/decl.go:194 +0x95e
go/types.(*Checker).packageObjects(0xc000162000)
	/usr/local/google/home/rfindley/src/go/src/go/types/resolver.go:662 +0x465
go/types.(*Checker).checkFiles(0xc000162000, {0xc0000560c0, 0x1, 0x1})
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:365 +0x149
go/types.(*Checker).Files(...)
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:340
go/types.(*Config).Check(0xc000015180?, {0x8ce0c0?, 0x6?}, 0x0?, {0xc0000560c0, 0x1, 0x1}, 0x6bb800?)
	/usr/local/google/home/rfindley/src/go/src/go/types/api.go:422 +0x7c
go/types_test.testFiles(0xc000007a00, {0x0?, 0x0}, {0xc00016bf40?, 0x1, 0x1}, {0xc0000101c8?, 0x1, 0x1}, 0x1, ...)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:188 +0x5e5
go/types_test.testPkg(0xc000007a00, {0xc000104f40, 0x1, 0x1}, 0xac?)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:431 +0x20b
go/types_test.TestManual(0xc000007a00)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:344 +0x18a
testing.tRunner(0xc000007a00, 0x70a100)
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 1
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1648 +0x3ad

I'll bisect.

CC @griesemer

@findleyr findleyr added this to the Go1.21 milestone Apr 28, 2023
@findleyr findleyr added release-blocker NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 28, 2023
@findleyr
Copy link
Member Author

Bisected to https://go.dev/cl/484615. I suppose it is simply that the assumption of that CL does not hold: we can "call" a tuple in the presence of invalid code.

@findleyr
Copy link
Member Author

Forgot to add: thank you @heschi for reporting the panic from VS Code (and for living on the bleeding edge).

@griesemer
Copy link
Contributor

griesemer commented Apr 29, 2023

Simpler repro:

package p

func _() { f() }

func f[T any]() (_, int) {}

@griesemer griesemer self-assigned this Apr 29, 2023
@griesemer
Copy link
Contributor

Likely caused by CL 484615. Fix forthcoming.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/490695 mentions this issue: go/types, types2: isParameterized must be able to handle tuples

@golang golang locked and limited conversation to collaborators Apr 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants