]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: use "invalid recursive type" instead of "illegal cycle" in error...
authorRobert Griesemer <gri@golang.org>
Thu, 22 Sep 2022 20:20:37 +0000 (13:20 -0700)
committerRobert Griesemer <gri@google.com>
Mon, 26 Sep 2022 21:33:48 +0000 (21:33 +0000)
This matches long-standing compiler behavior.

For #55326.

Change-Id: Ic5aa0dfb08d035f2c33532cc463c73a55cc020a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/433055
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
30 files changed:
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/expr.go
src/go/types/decl.go
src/go/types/expr.go
src/internal/types/testdata/check/cycles0.go
src/internal/types/testdata/check/cycles2.go
src/internal/types/testdata/check/cycles3.go
src/internal/types/testdata/check/cycles5.go
src/internal/types/testdata/check/decls0.go
src/internal/types/testdata/check/decls4.go
src/internal/types/testdata/check/issues0.go
src/internal/types/testdata/check/issues1.go
src/internal/types/testdata/check/typeinst0.go
src/internal/types/testdata/fixedbugs/issue39634.go
src/internal/types/testdata/fixedbugs/issue39938.go
src/internal/types/testdata/fixedbugs/issue41124.go
src/internal/types/testdata/fixedbugs/issue45550.go
src/internal/types/testdata/fixedbugs/issue46461.go
src/internal/types/testdata/fixedbugs/issue47796.go
src/internal/types/testdata/fixedbugs/issue48529.go
src/internal/types/testdata/fixedbugs/issue48582.go
src/internal/types/testdata/fixedbugs/issue48819.go
src/internal/types/testdata/fixedbugs/issue48951.go
src/internal/types/testdata/fixedbugs/issue48962.go
src/internal/types/testdata/fixedbugs/issue49043.go
src/internal/types/testdata/fixedbugs/issue49276.go
src/internal/types/testdata/fixedbugs/issue49439.go
src/internal/types/testdata/fixedbugs/issue51509.go
src/internal/types/testdata/fixedbugs/issue52698.go
src/internal/types/testdata/fixedbugs/issue52915.go

index bc92b64b7e19eb3b11721c88b29790b93935c4b3..f9d1431b82115f1b956b4558eac4207da87b94e1 100644 (file)
@@ -328,10 +328,11 @@ func (check *Checker) cycleError(cycle []Object) {
                check.validAlias(tname, Typ[Invalid])
        }
        var err error_
-       if tname != nil && check.conf.CompilerErrorMessages {
+       err.code = _InvalidDeclCycle
+       if tname != nil {
                err.errorf(obj, "invalid recursive type %s", objName)
        } else {
-               err.errorf(obj, "illegal cycle in declaration of %s", objName)
+               err.errorf(obj, "invalid cycle in declaration of %s", objName)
        }
        for range cycle {
                err.errorf(obj, "%s refers to", objName)
index 9834926b111cf042f3e6a6705421972dae9587ba..d3e54d051b1ee3decca2192127152ce469bc2757 100644 (file)
@@ -1392,7 +1392,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
                        // Prevent crash if the struct referred to is not yet set up.
                        // See analogous comment for *Array.
                        if utyp.fields == nil {
-                               check.error(e, _InvalidDeclCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        if len(e.ElemList) == 0 {
@@ -1468,7 +1468,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
                        // This is a stop-gap solution. Should use Checker.objPath to report entire
                        // path starting with earliest declaration in the source. TODO(gri) fix this.
                        if utyp.elem == nil {
-                               check.error(e, _InvalidTypeCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        n := check.indexedElts(e.ElemList, utyp.elem, utyp.len)
@@ -1495,7 +1495,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
                        // Prevent crash if the slice referred to is not yet set up.
                        // See analogous comment for *Array.
                        if utyp.elem == nil {
-                               check.error(e, _InvalidTypeCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        check.indexedElts(e.ElemList, utyp.elem, -1)
@@ -1504,7 +1504,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
                        // Prevent crash if the map referred to is not yet set up.
                        // See analogous comment for *Array.
                        if utyp.key == nil || utyp.elem == nil {
-                               check.error(e, _InvalidTypeCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        // If the map key type is an interface (but not a type parameter),
index a14df45dca6b0592eaf876177f839a8bd1ede280..a370c5c64685ff14599717bf084ce88e9d162a12 100644 (file)
@@ -325,10 +325,10 @@ func (check *Checker) cycleError(cycle []Object) {
        if tname != nil && tname.IsAlias() {
                check.validAlias(tname, Typ[Invalid])
        }
-       if tname != nil && compilerErrorMessages {
+       if tname != nil {
                check.errorf(obj, _InvalidDeclCycle, "invalid recursive type %s", objName)
        } else {
-               check.errorf(obj, _InvalidDeclCycle, "illegal cycle in declaration of %s", objName)
+               check.errorf(obj, _InvalidDeclCycle, "invalid cycle in declaration of %s", objName)
        }
        for range cycle {
                check.errorf(obj, _InvalidDeclCycle, "\t%s refers to", objName) // secondary error, \t indented
index c3cf46c137f9c8f305463282be947306931060d4..be03f2f4233752f9b8deabdc68f1824eead28dd6 100644 (file)
@@ -1371,7 +1371,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
                        // Prevent crash if the struct referred to is not yet set up.
                        // See analogous comment for *Array.
                        if utyp.fields == nil {
-                               check.error(e, _InvalidDeclCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        if len(e.Elts) == 0 {
@@ -1445,7 +1445,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
                        // This is a stop-gap solution. Should use Checker.objPath to report entire
                        // path starting with earliest declaration in the source. TODO(gri) fix this.
                        if utyp.elem == nil {
-                               check.error(e, _InvalidTypeCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        n := check.indexedElts(e.Elts, utyp.elem, utyp.len)
@@ -1472,7 +1472,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
                        // Prevent crash if the slice referred to is not yet set up.
                        // See analogous comment for *Array.
                        if utyp.elem == nil {
-                               check.error(e, _InvalidTypeCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        check.indexedElts(e.Elts, utyp.elem, -1)
@@ -1481,7 +1481,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
                        // Prevent crash if the map referred to is not yet set up.
                        // See analogous comment for *Array.
                        if utyp.key == nil || utyp.elem == nil {
-                               check.error(e, _InvalidTypeCycle, "illegal cycle in type declaration")
+                               check.error(e, _InvalidTypeCycle, "invalid recursive type")
                                goto Error
                        }
                        // If the map key type is an interface (but not a type parameter),
index 998f9f7da980116ccbae32f6fb796766fe4c19fa..aaf82d49d2ec3880652142bd9552f9f078b16b17 100644 (file)
@@ -8,10 +8,10 @@ import "unsafe"
 
 type (
        T0 int
-       T1 /* ERROR cycle */ T1
+       T1 /* ERROR invalid recursive type */ T1
        T2 *T2
 
-       T3 /* ERROR cycle */ T4
+       T3 /* ERROR invalid recursive type */ T4
        T4 T5
        T5 T3
 
@@ -20,10 +20,10 @@ type (
        T8 T6
 
        // arrays
-       A0 /* ERROR cycle */ [10]A0
+       A0 /* ERROR invalid recursive type */ [10]A0
        A1 [10]*A1
 
-       A2 /* ERROR cycle */ [10]A3
+       A2 /* ERROR invalid recursive type */ [10]A3
        A3 [10]A4
        A4 A2
 
@@ -34,12 +34,12 @@ type (
        L0 []L0
 
        // structs
-       S0 /* ERROR cycle */ struct{ _ S0 }
-       S1 /* ERROR cycle */ struct{ S1 }
+       S0 /* ERROR invalid recursive type */ struct{ _ S0 }
+       S1 /* ERROR invalid recursive type */ struct{ S1 }
        S2 struct{ _ *S2 }
        S3 struct{ *S3 }
 
-       S4 /* ERROR cycle */ struct{ S5 }
+       S4 /* ERROR invalid recursive type */ struct{ S5 }
        S5 struct{ S6 }
        S6 S4
 
@@ -53,9 +53,9 @@ type (
        F2 func(F2) F2
 
        // interfaces
-       I0 /* ERROR cycle */ interface{ I0 }
+       I0 /* ERROR invalid recursive type */ interface{ I0 }
 
-       I1 /* ERROR cycle */ interface{ I2 }
+       I1 /* ERROR invalid recursive type */ interface{ I2 }
        I2 interface{ I3 }
        I3 interface{ I1 }
 
@@ -74,7 +74,7 @@ type (
 
 // test case for issue #34771
 type (
-       AA /* ERROR cycle */ B
+       AA /* ERROR invalid recursive type */ B
        B C
        C [10]D
        D E
@@ -83,7 +83,7 @@ type (
 
 func _() {
        type (
-               t1 /* ERROR cycle */ t1
+               t1 /* ERROR invalid recursive type */ t1
                t2 *t2
 
                t3 t4 /* ERROR undeclared */
@@ -91,15 +91,15 @@ func _() {
                t5 t3
 
                // arrays
-               a0 /* ERROR cycle */ [10]a0
+               a0 /* ERROR invalid recursive type */ [10]a0
                a1 [10]*a1
 
                // slices
                l0 []l0
 
                // structs
-               s0 /* ERROR cycle */ struct{ _ s0 }
-               s1 /* ERROR cycle */ struct{ s1 }
+               s0 /* ERROR invalid recursive type */ struct{ _ s0 }
+               s1 /* ERROR invalid recursive type */ struct{ s1 }
                s2 struct{ _ *s2 }
                s3 struct{ *s3 }
 
@@ -112,7 +112,7 @@ func _() {
                f2 func(f2) f2
 
                // interfaces
-               i0 /* ERROR cycle */ interface{ i0 }
+               i0 /* ERROR invalid recursive type */ interface{ i0 }
 
                // maps
                m0 map[m0 /* ERROR invalid map key */ ]m0
@@ -135,32 +135,32 @@ type S struct {
 
 type (
        P1 *T9
-       T9 /* ERROR cycle */ T9
+       T9 /* ERROR invalid recursive type */ T9
 
-       T10 /* ERROR cycle */ T10
+       T10 /* ERROR invalid recursive type */ T10
        P2 *T10
 )
 
 func (T11) m() {}
 
-type T11 /* ERROR cycle */ struct{ T11 }
+type T11 /* ERROR invalid recursive type */ struct{ T11 }
 
-type T12 /* ERROR cycle */ struct{ T12 }
+type T12 /* ERROR invalid recursive type */ struct{ T12 }
 
 func (*T12) m() {}
 
 type (
        P3 *T13
-       T13 /* ERROR cycle */ T13
+       T13 /* ERROR invalid recursive type */ T13
 )
 
 // test cases for issue 18643
 // (type cycle detection when non-type expressions are involved)
 type (
-       T14 [len(T14 /* ERROR cycle */ {})]int
-       T15 [][len(T15 /* ERROR cycle */ {})]int
-       T16 map[[len(T16 /* ERROR cycle */ {1:2})]int]int
-       T17 map[int][len(T17 /* ERROR cycle */ {1:2})]int
+       T14 [len(T14 /* ERROR invalid recursive type */ {})]int
+       T15 [][len(T15 /* ERROR invalid recursive type */ {})]int
+       T16 map[[len(T16 /* ERROR invalid recursive type */ {1:2})]int]int
+       T17 map[int][len(T17 /* ERROR invalid recursive type */ {1:2})]int
 )
 
 // Test case for types depending on function literals (see also #22992).
@@ -169,7 +169,7 @@ type T22 = chan [unsafe.Sizeof(func(ch T20){ _ = <-ch })]byte
 
 func _() {
        type T0 func(T0)
-       type T1 /* ERROR cycle */ = func(T1)
+       type T1 /* ERROR invalid recursive type */ = func(T1)
        type T2 chan [unsafe.Sizeof(func(ch T2){ _ = <-ch })]byte
-       type T3 /* ERROR cycle */ = chan [unsafe.Sizeof(func(ch T3){ _ = <-ch })]byte
+       type T3 /* ERROR invalid recursive type */ = chan [unsafe.Sizeof(func(ch T3){ _ = <-ch })]byte
 }
index 1a7f40ae4b787e1f2704c9d1cd9913881ce081b1..8480b2939fd8dc1d03109ae6216cd2d017b76299 100644 (file)
@@ -70,25 +70,25 @@ type T interface {
 
 // Variations of this test case.
 
-type T1 /* ERROR cycle */ interface {
+type T1 /* ERROR invalid recursive type */ interface {
        m() [x1.m()[0]]int
 }
 
 var x1 T1
 
-type T2 /* ERROR cycle */ interface {
+type T2 /* ERROR invalid recursive type */ interface {
        m() [len(x2.m())]int
 }
 
 var x2 T2
 
-type T3 /* ERROR cycle */ interface {
+type T3 /* ERROR invalid recursive type */ interface {
        m() [unsafe.Sizeof(x3.m)]int
 }
 
 var x3 T3
 
-type T4 /* ERROR cycle */ interface {
+type T4 /* ERROR invalid recursive type */ interface {
        m() [unsafe.Sizeof(cast4(x4.m))]int // cast is invalid but we have a cycle, so all bets are off
 }
 
index 5e89b627f00a76b8b9dd3c69be2a85f473696cd5..433055140296a7b1e59decf5e1ec8866be0d1b64 100644 (file)
@@ -48,7 +48,7 @@ type (
 )
 
 type (
-       U /* ERROR cycle */ interface {
+       U /* ERROR invalid recursive type */ interface {
                V
        }
 
index c932ef92d0e4eefa2f1532458bebea358c176ddb..68aa913682dd2d29e559cb22ab073f5eea3e81bb 100644 (file)
@@ -98,12 +98,12 @@ var _ = err.Error()
 
 type (
        T1 interface { T2 }
-       T2 /* ERROR cycle */ T2
+       T2 /* ERROR invalid recursive type */ T2
 )
 
 type (
        T3 interface { T4 }
-       T4 /* ERROR cycle */ T5
+       T4 /* ERROR invalid recursive type */ T5
        T5 = T6
        T6 = T7
        T7 = T4
@@ -121,8 +121,8 @@ type I interface {
 
 // test cases for varias alias cycles
 
-type T10 /* ERROR cycle */ = *T10                 // issue #25141
-type T11 /* ERROR cycle */ = interface{ f(T11) }  // issue #23139
+type T10 /* ERROR invalid recursive type */ = *T10                 // issue #25141
+type T11 /* ERROR invalid recursive type */ = interface{ f(T11) }  // issue #23139
 
 // issue #18640
 type (
@@ -154,7 +154,7 @@ type (
 )
 
 // issue #8699
-type T12 /* ERROR cycle */ [len(a12)]int
+type T12 /* ERROR invalid recursive type */ [len(a12)]int
 var a12 = makeArray()
 func makeArray() (res T12) { return }
 
@@ -170,7 +170,7 @@ func f() [len(arr)]int
 func ff(ff /* ERROR not a type */ )
 func gg((gg /* ERROR not a type */ ))
 
-type T13 /* ERROR cycle */ [len(b13)]int
+type T13 /* ERROR invalid recursive type */ [len(b13)]int
 var b13 T13
 
 func g1() [unsafe.Sizeof(g1)]int
@@ -190,7 +190,7 @@ var c14 /* ERROR cycle */ T14
 type T14 [uintptr(unsafe.Sizeof(&c14))]byte
 
 // issue #34333
-type T15 /* ERROR cycle */ struct {
+type T15 /* ERROR invalid recursive type */ struct {
        f func() T16
        b T16
 }
index 7ba90c0504e6e68a57c75878563dedec0fb0e876..9f7a006a20d00ad26011ecca9b916cf248902b50 100644 (file)
@@ -71,10 +71,10 @@ type (
 type (
        Pi pi /* ERROR "not a type" */
 
-       a /* ERROR "illegal cycle" */ a
+       a /* ERROR "invalid recursive type" */ a
        a /* ERROR "redeclared" */ int
 
-       b /* ERROR "illegal cycle" */ c
+       b /* ERROR "invalid recursive type" */ c
        c d
        d e
        e b
@@ -101,10 +101,10 @@ type (
        S3 struct {
                x S2
        }
-       S4/* ERROR "illegal cycle" */ struct {
+       S4/* ERROR "invalid recursive type" */ struct {
                S4
        }
-       S5 /* ERROR "illegal cycle" */ struct {
+       S5 /* ERROR "invalid recursive type" */ struct {
                S6
        }
        S6 struct {
@@ -118,8 +118,8 @@ type (
        L2 []int
 
        A1 [10.0]int
-       A2 /* ERROR "illegal cycle" */ [10]A2
-       A3 /* ERROR "illegal cycle" */ [10]struct {
+       A2 /* ERROR "invalid recursive type" */ [10]A2
+       A3 /* ERROR "invalid recursive type" */ [10]struct {
                x A4
        }
        A4 [10]A3
@@ -154,10 +154,10 @@ type (
                I1
                I1
        }
-       I8 /* ERROR "illegal cycle" */ interface {
+       I8 /* ERROR "invalid recursive type" */ interface {
                I8
        }
-       I9 /* ERROR "illegal cycle" */ interface {
+       I9 /* ERROR "invalid recursive type" */ interface {
                I10
        }
        I10 interface {
index 2ce180fbbbfa0e532d816da859cce6dca2abfd6a..c1294eec86504ab76ffc073caa543453dadc6ce8 100644 (file)
@@ -100,7 +100,7 @@ func (V1) n() {}
 
 // alias receiver types (invalid due to cycles)
 type (
-       W0 /* ERROR illegal cycle */ = W1
+       W0 /* ERROR invalid recursive type */ = W1
        W1 = (W2)
        W2 = ((W0))
 )
@@ -120,14 +120,14 @@ func (B1 /* ERROR cannot define new methods on non-local type int */ ) n() {}
 
 // cycles
 type (
-       C2 /* ERROR illegal cycle */ = C2
-       C3 /* ERROR illegal cycle */ = C4
+       C2 /* ERROR invalid recursive type */ = C2
+       C3 /* ERROR invalid recursive type */ = C4
        C4 = C3
        C5 struct {
                f *C6
        }
        C6 = C5
-       C7 /* ERROR illegal cycle */  struct {
+       C7 /* ERROR invalid recursive type */  struct {
                f C8
        }
        C8 = C7
index bb9b8bdc43f8de1510a1862ca77eb2aa14dce031..5d6ed2bea7b5f71c156dd48a2b5767f0a189de1e 100644 (file)
@@ -277,7 +277,7 @@ type E = interface {
 
 // Test case from issue.
 // cmd/compile reports a cycle as well.
-type issue25301b /* ERROR cycle */ = interface {
+type issue25301b /* ERROR invalid recursive type */ = interface {
        m() interface{ issue25301b }
 }
 
index 41a19ad637025fe6d1d6f65041b5d85e7affaaf3..b986023cc196a58e58f44423f87799e1e661dccc 100644 (file)
@@ -143,8 +143,8 @@ type List3[TElem any] struct {
 }
 
 // Infinite generic type declarations must lead to an error.
-type inf1[T any] struct{ _ inf1 /* ERROR illegal cycle */ [T] }
-type inf2[T any] struct{ inf2 /* ERROR illegal cycle */ [T] }
+type inf1[T any] struct{ _ inf1 /* ERROR invalid recursive type */ [T] }
+type inf2[T any] struct{ inf2 /* ERROR invalid recursive type */ [T] }
 
 // The implementation of conversions T(x) between integers and floating-point
 // numbers checks that both T and x have either integer or floating-point
index 6423cb801f9971d69ea6f07eed270aca3b220f9a..c21cb53d0c80bff4f6ed4dab4fb3a523f7a1797c 100644 (file)
@@ -58,5 +58,5 @@ var _ T3[int] = T3[int](List[int]{1, 2, 3})
 
 // Self-recursive generic types are not permitted
 
-type self1[P any] self1 /* ERROR illegal cycle */ [P]
+type self1[P any] self1 /* ERROR invalid recursive type */ [P]
 type self2[P any] *self2[P] // this is ok
index 9df72f990ee9c2714e35331556e812a8e4bc402a..9ec208454a3d25a9ac3d30ec1e2edab22c3ab636 100644 (file)
@@ -35,7 +35,7 @@ type foo8[A any] interface { ~A /* ERROR cannot be a type parameter */ }
 func bar8[A foo8[A]](a A) {}
 
 // crash 9
-type foo9[A any] interface { foo9 /* ERROR illegal cycle */ [A] }
+type foo9[A any] interface { foo9 /* ERROR invalid recursive type */ [A] }
 func _() { var _ = new(foo9[int]) }
 
 // crash 12
@@ -65,11 +65,11 @@ type o18[T any] []func(_ o18[[]_ /* ERROR cannot use _ */ ])
 type Z19 [][[]Z19{}[0][0]]c19 /* ERROR undeclared */
 
 // crash 20
-type Z20 /* ERROR illegal cycle */ interface{ Z20 }
+type Z20 /* ERROR invalid recursive type */ interface{ Z20 }
 func F20[t Z20]() { F20(t /* ERROR invalid composite literal type */ {}) }
 
 // crash 21
-type Z21 /* ERROR illegal cycle */ interface{ Z21 }
+type Z21 /* ERROR invalid recursive type */ interface{ Z21 }
 func F21[T Z21]() { ( /* ERROR not used */ F21[Z21]) }
 
 // crash 24
index 6bc928484956466e8d8467c493dab2882d73f70f..633698d611011536bf3a5848415d33a4ccd2c23a 100644 (file)
@@ -23,7 +23,7 @@ type T1 struct {
         _ E1[T1]
 }
 
-type T2 /* ERROR illegal cycle */ struct {
+type T2 /* ERROR invalid recursive type */ struct {
         _ E2[T2]
 }
 
@@ -31,7 +31,7 @@ type T3 struct {
         _ E3[T3]
 }
 
-type T4 /* ERROR illegal cycle */ [10]E5[T4]
+type T4 /* ERROR invalid recursive type */ [10]E5[T4]
 
 type T5 struct {
        _ E0[E2[T5]]
@@ -49,6 +49,6 @@ type T8 struct {
        _ E0[[]E2[E0[E2[E2[T8]]]]]
 }
 
-type T9 /* ERROR illegal cycle */ [10]E2[E5[E2[T9]]]
+type T9 /* ERROR invalid recursive type */ [10]E2[E5[E2[T9]]]
 
 type T10 [10]E2[E5[E2[func(T10)]]]
index 4550dd732c149cc87d84b6cdb59c1343d6f90582..80d1ff4750a8da334403000e45514f47c3ade716 100644 (file)
@@ -6,7 +6,7 @@ package p
 
 // Test case from issue.
 
-type Nat /* ERROR cycle */ interface {
+type Nat /* ERROR invalid recursive type */ interface {
        Zero|Succ
 }
 
index 3eeaca0957a9bd54ee9dfcdd253e68d6a37f3fd9..498b1eb680a748b13ec44df7a901d79feeff18e9 100644 (file)
@@ -4,7 +4,7 @@
 
 package p
 
-type Builder /* ERROR illegal cycle */ [T interface{ struct{ Builder[T] } }] struct{}
+type Builder /* ERROR invalid recursive type */ [T interface{ struct{ Builder[T] } }] struct{}
 type myBuilder struct {
        Builder[myBuilder]
 }
index 4432402a300e9a4cec961fa762d81d0b6317c6d0..fce06f7ec7ade9e5f004863ba734ac211eb1ed51 100644 (file)
@@ -5,16 +5,16 @@
 package p
 
 // test case 1
-type T /* ERROR illegal cycle */ [U interface{ M() T[U] }] int
+type T /* ERROR invalid recursive type */ [U interface{ M() T[U] }] int
 
 type X int
 
 func (X) M() T[X] { return 0 }
 
 // test case 2
-type A /* ERROR illegal cycle */ [T interface{ A[T] }] interface{}
+type A /* ERROR invalid recursive type */ [T interface{ A[T] }] interface{}
 
 // test case 3
-type A2 /* ERROR illegal cycle */ [U interface{ A2[U] }] interface{ M() A2[U] }
+type A2 /* ERROR invalid recursive type */ [U interface{ A2[U] }] interface{ M() A2[U] }
 
 type I interface{ A2[I]; M() A2[I] }
index 6667ba4fec08551412c380b4cc0a34d413625ca6..4c59106e2e6f5fdcc19d6013a96c4ac658c82e68 100644 (file)
@@ -6,16 +6,16 @@ package p
 
 // parameterized types with self-recursive constraints
 type (
-       T1 /* ERROR illegal cycle */ [P T1[P]]                            interface{}
-       T2 /* ERROR illegal cycle */ [P, Q T2[P, Q]]                      interface{}
+       T1 /* ERROR invalid recursive type */ [P T1[P]]                            interface{}
+       T2 /* ERROR invalid recursive type */ [P, Q T2[P, Q]]                      interface{}
        T3[P T2[P, Q], Q interface{ ~string }] interface{}
 
-       T4a /* ERROR illegal cycle */ [P T4a[P]]                                                        interface{ ~int }
-       T4b /* ERROR illegal cycle */ [P T4b[int]]                                                      interface{ ~int }
-       T4c /* ERROR illegal cycle */ [P T4c[string]] interface{ ~int }
+       T4a /* ERROR invalid recursive type */ [P T4a[P]]                                                        interface{ ~int }
+       T4b /* ERROR invalid recursive type */ [P T4b[int]]                                                      interface{ ~int }
+       T4c /* ERROR invalid recursive type */ [P T4c[string]] interface{ ~int }
 
        // mutually recursive constraints
-       T5 /* ERROR illegal cycle */ [P T6[P]] interface{ int }
+       T5 /* ERROR invalid recursive type */ [P T6[P]] interface{ int }
        T6[P T5[P]] interface{ int }
 )
 
@@ -28,6 +28,6 @@ var (
 
 // test case from issue
 
-type Eq /* ERROR illegal cycle */ [a Eq[a]] interface {
+type Eq /* ERROR invalid recursive type */ [a Eq[a]] interface {
        Equal(that a) bool
 }
index a3653fa19c09618b6565c51df29555b756549d17..d7a70b166fb324b98351dc539c00dabd8949eff1 100644 (file)
@@ -4,7 +4,7 @@
 
 package p
 
-type T /* ERROR illegal cycle */ [U interface{ M() T[U, int] }] int
+type T /* ERROR invalid recursive type */ [U interface{ M() T[U, int] }] int
 
 type X int
 
index c12091be7902f460ee8e3022a94e151f69faeab5..9e1d526abfc5fe3f810feb86ddc6744a50343af0 100644 (file)
@@ -4,11 +4,11 @@
 
 package p
 
-type N /* ERROR cycle */ interface {
+type N /* ERROR invalid recursive type */ interface {
        int | N
 }
 
-type A /* ERROR cycle */ interface {
+type A /* ERROR invalid recursive type */ interface {
        int | B
 }
 
@@ -16,7 +16,7 @@ type B interface {
        int | A
 }
 
-type S /* ERROR cycle */ struct {
+type S /* ERROR invalid recursive type */ struct {
        I // ERROR interface contains type constraints
 }
 
index 9262110ea09e71e96c3494186beaba6c6c5f4db5..95e40ea009f5cbe3b5b23d00752511fcad111502 100644 (file)
@@ -6,7 +6,7 @@ package p
 
 import "unsafe"
 
-type T /* ERROR illegal cycle in declaration of T */ struct {
+type T /* ERROR invalid recursive type T */ struct {
        T
 }
 
index a9365281ee8abd599de7cd1fe0d3827c684b9310..c94b02779906fbe6ed0a6dd3799198c494a04ef5 100644 (file)
@@ -5,17 +5,17 @@
 package p
 
 type (
-        A1[P any] [10]A1 /* ERROR illegal cycle */ [P]
-        A2[P any] [10]A2 /* ERROR illegal cycle */ [*P]
+        A1[P any] [10]A1 /* ERROR invalid recursive type */ [P]
+        A2[P any] [10]A2 /* ERROR invalid recursive type */ [*P]
         A3[P any] [10]*A3[P]
 
         L1[P any] []L1[P]
 
-        S1[P any] struct{ f S1 /* ERROR illegal cycle */ [P] }
-        S2[P any] struct{ f S2 /* ERROR illegal cycle */ [*P] } // like example in issue
+        S1[P any] struct{ f S1 /* ERROR invalid recursive type */ [P] }
+        S2[P any] struct{ f S2 /* ERROR invalid recursive type */ [*P] } // like example in issue
         S3[P any] struct{ f *S3[P] }
 
-        I1[P any] interface{ I1 /* ERROR illegal cycle */ [P] }
-        I2[P any] interface{ I2 /* ERROR illegal cycle */ [*P] }
+        I1[P any] interface{ I1 /* ERROR invalid recursive type */ [P] }
+        I2[P any] interface{ I2 /* ERROR invalid recursive type */ [*P] }
         I3[P any] interface{ *I3 /* ERROR interface contains type constraints */ [P] }
 )
index 4270da1c733741b190d6175fb25fe1cc75e8b540..05c681dcb93b9cb72f7c0b1e0bd58a8513a8febb 100644 (file)
@@ -8,6 +8,6 @@ type T0[P any] struct {
        f P
 }
 
-type T1 /* ERROR illegal cycle */ struct {
+type T1 /* ERROR invalid recursive type */ struct {
        _ T0[T1]
 }
index a360457d9ffd2dd30a97f43d2d55263c163e3a87..8fe8629feb780b3866bb5233abc9b7b8cdb4f5fb 100644 (file)
@@ -6,13 +6,13 @@ package p
 
 // The example from the issue.
 type (
-       N[P any] M /* ERROR illegal cycle */ [P]
-       M[P any] N /* ERROR illegal cycle */ [P]
+       N[P any] M /* ERROR invalid recursive type */ [P]
+       M[P any] N /* ERROR invalid recursive type */ [P]
 )
 
 // A slightly more complicated case.
 type (
-       A[P any] B /* ERROR illegal cycle */ [P]
+       A[P any] B /* ERROR invalid recursive type */ [P]
        B[P any] C[P]
        C[P any] A[P]
 )
index 8839087b50671221dd56a6b05dad3bfa199ef33a..ab5794a1c51b5fa37638788c8f82cf4a5fc7f77d 100644 (file)
@@ -6,7 +6,7 @@ package p
 
 import "unsafe"
 
-type S /* ERROR illegal cycle in declaration of S */ struct {
+type S /* ERROR invalid recursive type S */ struct {
        _ [unsafe.Sizeof(s)]byte
 }
 
@@ -15,7 +15,7 @@ var s S
 // Since f is a pointer, this case could be valid.
 // But it's pathological and not worth the expense.
 type T struct {
-       f *[unsafe.Sizeof(T /* ERROR illegal cycle in type declaration */ {})]int
+       f *[unsafe.Sizeof(T /* ERROR invalid recursive type */ {})]int
 }
 
 // a mutually recursive case using unsafe.Sizeof
@@ -25,7 +25,7 @@ type (
        }
 
        B1 struct {
-               _ [unsafe.Sizeof(A1 /* ERROR illegal cycle in type declaration */ {})]int
+               _ [unsafe.Sizeof(A1 /* ERROR invalid recursive type */ {})]int
        }
 )
 
@@ -36,11 +36,11 @@ type (
        }
 
        B2 struct {
-               f [len(A2 /* ERROR illegal cycle in type declaration */ {}.f)]int
+               f [len(A2 /* ERROR invalid recursive type */ {}.f)]int
        }
 )
 
 // test case from issue
 type a struct {
-       _ [42 - unsafe.Sizeof(a /* ERROR illegal cycle in type declaration */ {})]byte
+       _ [42 - unsafe.Sizeof(a /* ERROR invalid recursive type */ {})]byte
 }
index 6cc838b3b30104c299e86b74ad604282dbb9b8c4..b8ad4955aba8d0c6b9ef6d4a78ee6021f0eb7f9b 100644 (file)
@@ -6,12 +6,12 @@ package p
 
 import "unsafe"
 
-type T0 /* ERROR illegal cycle */ [P T0[P]] struct{}
+type T0 /* ERROR invalid recursive type */ [P T0[P]] struct{}
 
-type T1 /* ERROR illegal cycle */ [P T2[P]] struct{}
+type T1 /* ERROR invalid recursive type */ [P T2[P]] struct{}
 type T2[P T1[P]] struct{}
 
-type T3 /* ERROR illegal cycle */ [P interface{ ~struct{ f T3[int] } }] struct{}
+type T3 /* ERROR invalid recursive type */ [P interface{ ~struct{ f T3[int] } }] struct{}
 
 // valid cycle in M
 type N[P M[P]] struct{}
@@ -23,4 +23,4 @@ type TC[P [unsafe.Sizeof(func() {
 })]byte] struct{}
 
 // test case from issue
-type X /* ERROR illegal cycle */ [T any, PT X[T]] interface{}
+type X /* ERROR invalid recursive type */ [T any, PT X[T]] interface{}
index 5ae47176d07e2f91cc1ba49a16242e2709f3bbe7..64f5d7e5ba56c97c2559f6aa4c35db63ef5b305a 100644 (file)
@@ -4,4 +4,4 @@
 
 package p
 
-type T /* ERROR illegal cycle */ T.x
+type T /* ERROR invalid recursive type */ T.x
index d1b06a210da1cd3bb84a3c5f7589d9bc4d978ca1..ca794f8b1617b57808c5bea9de84bd63fe7c13aa 100644 (file)
@@ -9,7 +9,7 @@ type T[P any] struct {
        _ P
 }
 
-type S /* ERROR illegal cycle */ struct {
+type S /* ERROR invalid recursive type */ struct {
        _ T[S]
 }
 
index 2c38e5bccaf5aade11a157e19557982b47c34505..6c43386efcb70e15fdd41b49752268a56d2a4c89 100644 (file)
@@ -7,7 +7,7 @@ package p
 import "unsafe"
 
 type T[P any] struct {
-       T /* ERROR illegal cycle */ [P]
+       T /* ERROR   invalid recursive type */ [P]
 }
 
 func _[P any]() {