Source file src/cmd/compile/internal/syntax/testdata/tparams.go

     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 t[a, b /* ERROR missing type constraint */ ] struct{}
     8  type t[a t, b t, c /* ERROR missing type constraint */ ] struct{}
     9  type t struct {
    10  	t [n]byte
    11  	t[a]
    12  	t[a, b]
    13  }
    14  type t interface {
    15  	t[a]
    16  	m /* ERROR method must have no type parameters */ [_ _, /* ERROR mixed */ _]()
    17  	t[a, b]
    18  }
    19  
    20  func f[ /* ERROR empty type parameter list */ ]()
    21  func f[a, b /* ERROR missing type constraint */ ]()
    22  func f[a t, b t, c /* ERROR missing type constraint */ ]()
    23  
    24  func f[a b,  /* ERROR expected ] */ 0] ()
    25  
    26  // go.dev/issue/49482
    27  type (
    28  	t[a *[]int] struct{}
    29  	t[a *t,] struct{}
    30  	t[a *t|[]int] struct{}
    31  	t[a *t|t,] struct{}
    32  	t[a *t|~t,] struct{}
    33  	t[a *struct{}|t] struct{}
    34  	t[a *t|struct{}] struct{}
    35  	t[a *struct{}|~t] struct{}
    36  )
    37  
    38  // go.dev/issue/51488
    39  type (
    40  	t[a *t|t,] struct{}
    41  	t[a *t|t, b t] struct{}
    42  	t[a *t|t] struct{}
    43  	t[a *[]t|t] struct{}
    44  	t[a ([]t)] struct{}
    45  	t[a ([]t)|t] struct{}
    46  )
    47  
    48  // go.dev/issue/60812
    49  type (
    50  	t [t]struct{}
    51  	t [[]t]struct{}
    52  	t [[t]t]struct{}
    53  	t [/* ERROR missing type parameter name or invalid array length */ t[t]]struct{}
    54  	t [t t[t], /* ERROR missing type parameter name */ t[t]]struct{}
    55  	t [/* ERROR missing type parameter name */ t[t], t t[t]]struct{}
    56  	t [/* ERROR missing type parameter name */ t[t], t[t]]struct{} // report only first error
    57  )
    58  

View as plain text