go/types, types2: more concise error messages for cycle errors

If a cycle has length 1, don't enumerate the single cycle entry;
instead just mention "refers to itself". For instance, for an
invalid recursive type T we now report:

	invalid recursive type: T refers to itself

instead of:

	invalid recursive type T
		T refers to
		T

Adjust tests to check for the different error messages.

Change-Id: I5bd46f62fac0cf167f0d0c9a55f952981d294ff4
Reviewed-on: https://go-review.googlesource.com/c/go/+/436295
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
This commit is contained in:
Robert Griesemer 2022-09-28 16:44:53 -07:00 committed by Gopher Robot
parent ecd112c0d1
commit e22af33b48
19 changed files with 83 additions and 47 deletions

View file

@ -8,6 +8,6 @@
package main
var z struct { // GC_ERROR "initialization cycle for z"
var z struct { // GC_ERROR "initialization cycle: z refers to itself"
e [cap(z.e)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
}