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 package p
6
7 type (
8 // these need a comma to disambiguate
9 _[P *T,] struct{}
10 _[P *T, _ any] struct{}
11 _[P (*T),] struct{}
12 _[P (*T), _ any] struct{}
13 _[P (T),] struct{}
14 _[P (T), _ any] struct{}
15
16 // these parse as name followed by type
17 _[P *struct{}] struct{}
18 _[P (*struct{})] struct{}
19 _[P ([]int)] struct{}
20
21 // array declarations
22 _ [P(T)]struct{}
23 _ [P((T))]struct{}
24 _ [P * *T]struct{}
25 _ [P * T]struct{}
26 _ [P(*T)]struct{}
27 _ [P(**T)]struct{}
28 _ [P * T - T]struct{}
29 _ [P*T-T, /* ERROR "unexpected comma" */ ]struct{}
30 _ [10, /* ERROR "unexpected comma" */ ]struct{}
31
32 // These should be parsed as generic type declarations.
33 _[P *struct /* ERROR "expected expression" */ {}|int] struct{}
34 _[P *struct /* ERROR "expected expression" */ {}|int|string] struct{}
35 )
36
View as plain text