File tree Expand file tree Collapse file tree 2 files changed +21
-17
lines changed
src/internal/types/testdata/fixedbugs Expand file tree Collapse file tree 2 files changed +21
-17
lines changed Original file line number Diff line number Diff line change 11<!--{
22 "Title": "The Go Programming Language Specification",
3- "Subtitle": "Language version go1.26 (Nov 9 , 2025)",
3+ "Subtitle": "Language version go1.26 (Nov 12 , 2025)",
44 "Path": "/ref/spec"
55}-->
66
@@ -2686,22 +2686,6 @@ <h3 id="Type_parameter_declarations">Type parameter declarations</h3>
26862686with a generic type.
26872687</ p >
26882688
2689- < p >
2690- Within a type parameter list of a generic type < code > T</ code > , a type constraint
2691- may not (directly, or indirectly through the type parameter list of another
2692- generic type) refer to < code > T</ code > .
2693- </ p >
2694-
2695- < pre >
2696- type T1[P T1[P]] … // illegal: T1 refers to itself
2697- type T2[P interface{ T2[int] }] … // illegal: T2 refers to itself
2698- type T3[P interface{ m(T3[int])}] … // illegal: T3 refers to itself
2699- type T4[P T5[P]] … // illegal: T4 refers to T5 and
2700- type T5[P T4[P]] … // T5 refers to T4
2701-
2702- type T6[P int] struct{ f *T6[P] } // ok: reference to T6 is not in type parameter list
2703- </ pre >
2704-
27052689< h4 id ="Type_constraints "> Type constraints</ h4 >
27062690
27072691< p >
Original file line number Diff line number Diff line change 1+ // Copyright 2025 The Go Authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style
3+ // license that can be found in the LICENSE file.
4+
5+ // Test cases that were invalid because of cycles before the respective language change.
6+ // Some are still invalid, but not because of cycles.
7+
8+ package p
9+
10+ type T1 [P T1 [P ]] struct {}
11+ type T2 [P interface {
12+ T2 [int /* ERROR "int does not satisfy interface{T2[int]}" */ ]
13+ }] struct {}
14+ type T3 [P interface {
15+ m (T3 [int /* ERROR "int does not satisfy interface{m(T3[int])}" */ ])
16+ }] struct {}
17+ type T4 [P T5 [P /* ERROR "P does not satisfy T4[P]" */ ]] struct {}
18+ type T5 [P T4 [P /* ERROR "P does not satisfy T5[P]" */ ]] struct {}
19+
20+ type T6 [P int ] struct { f * T6 [P ] }
You can’t perform that action at this time.
0 commit comments