]> Cypherpunks.ru repositories - gostls13.git/blob - src/go/parser/testdata/typeset.go2
7844c22212298a306a5347b24078069cdc266e9e
[gostls13.git] / src / go / parser / testdata / typeset.go2
1 // Copyright 2021 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 // This file contains test cases for typeset-only constraint elements.
6 // TODO(gri) gofmt once/if gofmt supports this notation.
7
8 package p
9
10 type (
11         _[_ t] t
12         _[_ ~t] t
13         _[_ t|t] t
14         _[_ ~t|t] t
15         _[_ t|~t] t
16         _[_ ~t|~t] t
17
18         _[_ t, _, _ t|t] t
19         _[_ t, _, _ ~t|t] t
20         _[_ t, _, _ t|~t] t
21         _[_ t, _, _ ~t|~t] t
22
23         _[_ t.t] t
24         _[_ ~t.t] t
25         _[_ t.t|t.t] t
26         _[_ ~t.t|t.t] t
27         _[_ t.t|~t.t] t
28         _[_ ~t.t|~t.t] t
29
30         _[_ t, _, _ t.t|t.t] t
31         _[_ t, _, _ ~t.t|t.t] t
32         _[_ t, _, _ t.t|~t.t] t
33         _[_ t, _, _ ~t.t|~t.t] t
34
35         _[_ struct{}] t
36         _[_ ~struct{}] t
37
38         _[_ struct{}|t] t
39         _[_ ~struct{}|t] t
40         _[_ struct{}|~t] t
41         _[_ ~struct{}|~t] t
42
43         _[_ t|struct{}] t
44         _[_ ~t|struct{}] t
45         _[_ t|~struct{}] t
46         _[_ ~t|~struct{}] t
47 )
48
49 // Single-expression type parameter lists and those that don't start
50 // with a (type parameter) name are considered array sizes.
51 // The term must be a valid expression (it could be a type incl. a
52 // tilde term) but the type-checker will complain.
53 type (
54         _[t] t
55         _[t|t] t
56
57         // These are invalid and the type-checker will complain.
58         _[~t] t
59         _[~t|t] t
60         _[t|~t] t
61         _[~t|~t] t
62 )
63
64 type _[_ t, t /* ERROR "type parameters must be named" */ ] t
65 type _[_ ~t, t /* ERROR "type parameters must be named" */ ] t
66 type _[_ t, ~ /* ERROR "type parameters must be named" */ t] t
67 type _[_ ~t, ~ /* ERROR "type parameters must be named" */ t] t
68
69 type _[_ t|t, t /* ERROR "type parameters must be named" */ |t] t
70 type _[_ ~t|t, t /* ERROR "type parameters must be named" */ |t] t
71 type _[_ t|t, ~ /* ERROR "type parameters must be named" */ t|t] t
72 type _[_ ~t|t, ~ /* ERROR "type parameters must be named" */ t|t] t