Skip to content

go/types: panic when enabling reverseTypeInference with -lang=go1.17 #59639

Closed
@findleyr

Description

@findleyr

The following test crashes go/types:

// -reverseTypeInference -lang=go1.17

// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

func f[P any](P) {}

var v func(int) = f

Output:

    --- FAIL: TestFixedbugs/issueNNNNN.go (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x573f55]

goroutine 471 [running]:
testing.tRunner.func1.2({0x697cc0, 0x8c5fa0})
	/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({0x697cc0?, 0x8c5fa0?})
	/usr/local/google/home/rfindley/src/go/src/runtime/panic.go:913 +0x21f
go/types.(*Checker).handleBailout(0xc0001c4b40, 0xc0003b78e8)
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:332 +0x88
panic({0x697cc0?, 0x8c5fa0?})
	/usr/local/google/home/rfindley/src/go/src/runtime/panic.go:913 +0x21f
go/types.(*Checker).funcInst(0xc0001c4b40, 0xc000262240, 0xc0002622c0?, 0xc000262300, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/call.go:29 +0x95
go/types.(*Checker).nonGeneric(0xc0001c4b40, {0x74dc88?, 0xc000262240?}, 0xc000262300)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1282 +0x145
go/types.(*Checker).rawExpr(0xc0001c4b40, {0x74dc88, 0xc000262240}, 0xc000262300, {0x74e4c0?, 0xc0001f1200?}, {0x0?, 0x0?}, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1257 +0x1e5
go/types.(*Checker).expr(0x40380b?, {0x74dc88?, 0xc000262240?}, 0x0?, {0x74e4c0?, 0xc0001f1200?})
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1787 +0x45
go/types.(*Checker).varDecl(0x695940?, 0xc0000b19e0, {0xc000057ee8?, 0x1, 0x1}, {0x74e430, 0xc0001f11e0}, {0x74e4c0, 0xc0001f1200})
	/usr/local/google/home/rfindley/src/go/src/go/types/decl.go:513 +0x16c
go/types.(*Checker).objDecl(0xc0001c4b40, {0x7503f8, 0xc0000b19e0}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/decl.go:194 +0x95e
go/types.(*Checker).packageObjects(0xc0001c4b40)
	/usr/local/google/home/rfindley/src/go/src/go/types/resolver.go:662 +0x465
go/types.(*Checker).checkFiles(0xc0001c4b40, {0xc000057ec8, 0x1, 0x1})
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:362 +0x149
go/types.(*Checker).Files(...)
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:337
go/types.(*Config).Check(0xc000262080?, {0x8bdc80?, 0x6?}, 0x0?, {0xc000057ec8, 0x1, 0x1}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/api.go:422 +0x7c
go/types_test.testFiles(0xc0000836c0, {0x0?, 0x0}, {0xc0003b7f50?, 0x1, 0x1}, {0xc0003a6768?, 0x1, 0x1}, 0x0, ...)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:188 +0x5e5
go/types_test.testPkg(0xc0000836c0, {0xc0000c1f50, 0x1, 0x1}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:431 +0x20b
go/types_test.testDirFiles.func1(0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:396 +0x3c
testing.tRunner(0xc0000836c0, 0xc0001f1080)
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 277
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1648 +0x3ad

Fix incoming.

Metadata

Metadata

Assignees

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