]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile/internal/types2: avoid infinite expansion for invalid recursive generic...
authorRobert Griesemer <gri@golang.org>
Thu, 14 Oct 2021 04:13:05 +0000 (21:13 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 14 Oct 2021 15:16:55 +0000 (15:16 +0000)
commitad99d8840edc655a757570d3d4ec62ad8f4df8a7
treedcbafd2e1cd0e26c71932e0a422582c3b03057d0
parent24e798e2876f05d628f1e9a32ce8c7f4a3ed3268
cmd/compile/internal/types2: avoid infinite expansion for invalid recursive generic types

The algorithm for detecting invalid recursive types that
expand indefinitely suffered from the exact problem is was
intended to detect: if the indefinite expansion is happening
through type parameters, the algorithm ended up in an infinite
sequence of instantiations. (This is only a problem for generic
types).

Changed the algorithm to always only consider the "original"
uninstantiated types. This avoids the problem but it will also
not detect some invalid recursive generic types anymore. That
requires a more sophisticated type flow analysis.
Opened #48962 to track.

Addressed with help from @findleyr.

For #48951.

Change-Id: Ie29cea8f810dae55153dbb1b17c9390cd823c2d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/355732
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/testdata/check/issues.go2
src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2
src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2
src/cmd/compile/internal/types2/testdata/fixedbugs/issue48951.go2 [new file with mode: 0644]