Skip to content
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

go/types, types2: Simple generic code makes compiler loop forever #48671

Closed
aDotInTheVoid opened this issue Sep 28, 2021 · 3 comments
Closed
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

@aDotInTheVoid
Copy link

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

$ go version
go version devel go1.18-534dfb2 Tue Sep 28 03:21:58 2021 +0000 darwin/amd64

Does this issue reproduce with the latest release?

No, requires generics

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/nixon/Library/Caches/go-build"
GOENV="/Users/nixon/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/nixon/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/nixon/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/nixon/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/nixon/sdk/gotip/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.18-534dfb2 Tue Sep 28 03:21:58 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/nixon/dev/go/gnom/go.mod"
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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/14/bhp6wfld6f9gyw31rw492_p40000gn/T/go-build1866204895=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel go1.18-534dfb2 Tue Sep 28 03:21:58 2021 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.18-534dfb2 Tue Sep 28 03:21:58 2021 +0000
uname -v: Darwin Kernel Version 19.6.0: Tue Aug 24 20:28:00 PDT 2021; root:xnu-6153.141.40~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H1417
lldb --version: lldb-1103.0.22.10
Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)

What did you do?

package slow

type Maker[T any] func() T

func (m Maker[T]) Culprit() Maker[[]T] {
	return nil
}

What did you expect to see?

Program compiles sucessfully

What did you see instead?

Compiller loops forever. I stoped it after 9 mins.

Other potentialy usefull things

package slow

type Maker[T any] func() T

func (m Maker[T]) Culprit() Maker[T] {
	return nil
}

both compiles fine

@findleyr findleyr changed the title Simple generic code makes compiler loop forever go/types, types2: Simple generic code makes compiler loop forever Sep 28, 2021
@findleyr
Copy link
Contributor

This is an infinite recursion in the type checker.

CC @griesemer

@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 Sep 28, 2021
@findleyr findleyr added this to the Go1.18 milestone Sep 28, 2021
@findleyr
Copy link
Contributor

Thank you for the report.

Simpler reproducer:

type N[T any] N[*T]

We recurse while expanding N[*T].

This can probably be duped to #48098, though it is important to note that we must also detect this recursion through method declarations.

@findleyr
Copy link
Contributor

Closing as a dupe of #48098

@golang golang locked and limited conversation to collaborators Jun 23, 2023
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

4 participants