summaryrefslogtreecommitdiffstats
path: root/src/cmd/compile/internal/syntax/testdata/tparams.go
blob: 4b68a1585f9635861a19d3cc4f2f8af2f8d79e94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

type t[a, b /* ERROR missing type constraint */ ] struct{}
type t[a t, b t, c /* ERROR missing type constraint */ ] struct{}
type t struct {
	t [n]byte
	t[a]
	t[a, b]
}
type t interface {
	t[a]
	m /* ERROR method must have no type parameters */ [_ _, /* ERROR mixed */ _]()
	t[a, b]
}

func f[ /* ERROR empty type parameter list */ ]()
func f[a, b /* ERROR missing type constraint */ ]()
func f[a t, b t, c /* ERROR missing type constraint */ ]()

func f[a b,  /* ERROR expected ] */ 0] ()

// go.dev/issue/49482
type (
	t[a *[]int] struct{}
	t[a *t,] struct{}
	t[a *t|[]int] struct{}
	t[a *t|t,] struct{}
	t[a *t|~t,] struct{}
	t[a *struct{}|t] struct{}
	t[a *t|struct{}] struct{}
	t[a *struct{}|~t] struct{}
)

// go.dev/issue/51488
type (
	t[a *t|t,] struct{}
	t[a *t|t, b t] struct{}
	t[a *t|t] struct{}
	t[a *[]t|t] struct{}
	t[a ([]t)] struct{}
	t[a ([]t)|t] struct{}
)

// go.dev/issue/60812
type (
	t [t]struct{}
	t [[]t]struct{}
	t [[t]t]struct{}
	t [/* ERROR missing type parameter name or invalid array length */ t[t]]struct{}
	t [t t[t], /* ERROR missing type parameter name */ t[t]]struct{}
	t [/* ERROR missing type parameter name */ t[t], t t[t]]struct{}
	t [/* ERROR missing type parameter name */ t[t], t[t]]struct{} // report only first error
)