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

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

aDotInTheVoid opened this issue Sep 28, 2021 · 3 comments

Comments

@aDotInTheVoid
Copy link

@aDotInTheVoid aDotInTheVoid commented Sep 28, 2021

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

@findleyr findleyr commented Sep 28, 2021

This is an infinite recursion in the type checker.

CC @griesemer

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Sep 28, 2021

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.

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Sep 28, 2021

Closing as a dupe of #48098

Loading

@findleyr findleyr closed this Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants