]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: report type loop for invalid recursive types
authorMatthew Dempsky <mdempsky@google.com>
Tue, 29 Sep 2020 09:11:10 +0000 (02:11 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 29 Sep 2020 22:49:58 +0000 (22:49 +0000)
commit0e85fd7561de869add933801c531bf25dee9561c
treeed31088cd83df0c80c556d19fb2967cde0bb351b
parentaf9c5e5dbc3a5abc49aa3ac45da1b533b0d238a6
cmd/compile: report type loop for invalid recursive types

Similar to how we report initialization loops in initorder.go and type
alias loops in typecheck.go, this CL updates align.go to warn about
invalid recursive types. The code is based on the loop code from
initorder.go, with minimal changes to adapt from detecting
variable/function initialization loops to detecting type declaration
loops.

Thanks to Cuong Manh Le for investigating this, helping come up with
test cases, and exploring solutions.

Fixes #41575
Updates #41669.

Change-Id: Idb2cb8c5e1d645e62900e178fcb50af33e1700a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/258177
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/gc/align.go
src/cmd/compile/internal/gc/subr.go
test/fixedbugs/bug195.go
test/fixedbugs/issue22904.go
test/fixedbugs/issue23823.go
test/fixedbugs/issue41575.go [new file with mode: 0644]