]> Cypherpunks.ru repositories - gostls13.git/blob - src/go/parser/testdata/tparams.go2
go/parser: better error messages for incorrect type parameter list
[gostls13.git] / src / go / parser / testdata / tparams.go2
1 // Copyright 2020 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 package p
6
7 type _[a, b] /* ERROR "missing type constraint" */ struct{}
8 type _[a t, b t, c]  /* ERROR "missing type constraint" */ struct{}
9 type _ struct {
10         t [n]byte
11         t[a]
12         t[a,]
13         t[a, b]
14         t[a, b,]
15 }
16 type _ struct {
17         t [n, /* ERROR "unexpected comma; expecting ]" */ ]byte
18 }
19 type _ interface {
20         t[a]
21         t[a,]
22         m[ /* ERROR "method must have no type parameters" */ _ _, /* ERROR mixed */ _]()
23         t[a, b]
24         t[a, b,]
25 }
26
27 func _[] /* ERROR "empty type parameter list" */ ()
28 func _[a, b ] /* ERROR "missing type constraint" */ ()
29 func _[a t, b t, c] /* ERROR "missing type constraint" */ ()
30
31 // TODO(rfindley) incorrect error message (see existing TODO in parser)
32 func f[a b, 0 /* ERROR "expected '\)', found 0" */ ] ()
33
34 // go.dev/issue/49482
35 type (
36         _[a *[]int] struct{}
37         _[a *t,] struct{}
38         _[a *t|[]int] struct{}
39         _[a *t|t,] struct{}
40         _[a *t|~t,] struct{}
41         _[a *struct{}|t] struct{}
42         _[a *t|struct{}] struct{}
43         _[a *struct{}|~t] struct{}
44 )
45
46 // go.dev/issue/51488
47 type (
48         _[a *t|t,] struct{}
49         _[a *t|t, b t] struct{}
50         _[a *t|t] struct{}
51         _[a *[]t|t] struct{}
52         _[a ([]t)] struct{}
53         _[a ([]t)|t] struct{}
54 )
55
56 // go.dev/issue/60812
57 type (
58         _ [t]struct{}
59         _ [[]t]struct{}
60         _ [[t]t]struct{}
61         _ [t /* ERROR "missing type parameter name or invalid array length" */ [t]]struct{}
62         _ [t t[t], t /* ERROR "missing type parameter name" */ [t]]struct{}
63         _ [t /* ERROR "missing type parameter name" */ [t], t t[t]]struct{}
64         _ [t /* ERROR "missing type parameter name" */ [t], t[t]]struct{} // report only first error
65 )