Skip to content

cmd/compile: failed to compile some recursive generic type #54535

@johejo

Description

@johejo

What version of Go are you using (go version)?

$ go version
go version devel go1.20-a719a78c1b Fri Aug 19 00:29:18 2022 +0000 darwin/arm64

Does this issue reproduce with the latest release?

tip only

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/mitsuoheijo/Library/Caches/go-build"
GOENV="/Users/mitsuoheijo/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/mitsuoheijo/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mitsuoheijo/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/mitsuoheijo/ghq/github.com/golang/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/mitsuoheijo/ghq/github.com/golang/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="devel go1.20-a719a78c1b Fri Aug 19 00:29:18 2022 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mitsuoheijo/ghq/github.com/johejo/sandbox/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bq/s3vkkxm17jq79lx5qy3856zh0000gn/T/go-build3085638013=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

type node[T any] struct {
	items    items[T]
	children items[*node[T]]
}

func (n *node[T]) f(i int, j int) bool {
	if len(n.children[i].items) < j {
		return false
	}
	return true
}

type items[T any] []T

func main() {
	_ = node[int]{}
	println("hello")
}

What did you expect to see?

$ go run .
hello

What did you see instead?

$ gotip run .
# github.com/johejo/sandbox
./main.go:9:22: n.children[i].items undefined (type go.shape.*uint8 has no field or method items)

This might be some regression.
I found this problem while using google/btree.
https://github.com/google/btree

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions