Skip to content

go/types: report invalid recursive type on valid code #79250

Description

@wdvxdr1123

Go version

gotip

Output of go env in your module/workspace:

.

What did you do?

package main

import (
	"unsafe"
)

type F interface {
	A() V
}

const size = unsafe.Sizeof(F(nil))

type V struct {
	_ [size]int
}

func main() {
	_ = V{}
}

https://go.dev/play/p/PTaVuR0dIyw?v=gotip

What did you see happen?

./prog.go:8:6: invalid recursive type F
	./prog.go:8:6: F refers to V
	./prog.go:14:6: V refers to size
	./prog.go:12:7: size refers to F

What did you expect to see?

compile pass
This issue does not exist on go1.25.
cc @griesemer @mrkfrmn

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions