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.
5 // This file contains test cases for typeset-only constraint elements.
29 _[_ t, _, _ t.t|t.t] t
30 _[_ t, _, _ ~t.t|t.t] t
31 _[_ t, _, _ t.t|~t.t] t
32 _[_ t, _, _ ~t.t|~t.t] t
47 // test cases for go.dev/issue/49175
52 t [ /* ERROR missing type parameter name */ t[0]]t
55 // test cases for go.dev/issue/49174
59 func _[_ []t | t]() {}
60 func _[_ [1]t | t]() {}
61 func _[_ t | []t]() {}
62 func _[_ []t | []t]() {}
63 func _[_ [1]t | [1]t]() {}
64 func _[_ t[t] | t[t]]() {}
66 // Single-expression type parameter lists and those that don't start
67 // with a (type parameter) name are considered array sizes.
68 // The term must be a valid expression (it could be a type incl. a
69 // tilde term) but the type-checker will complain.
74 // These are invalid and the type-checker will complain.
82 _[_ t, t /* ERROR missing type constraint */ ] t
83 _[_ ~t, t /* ERROR missing type constraint */ ] t
84 _[_ t, /* ERROR missing type parameter name */ ~t] t
85 _[_ ~t, /* ERROR missing type parameter name */ ~t] t
87 _[_ t|t, /* ERROR missing type parameter name */ t|t] t
88 _[_ ~t|t, /* ERROR missing type parameter name */ t|t] t
89 _[_ t|t, /* ERROR missing type parameter name */ ~t|t] t
90 _[_ ~t|t, /* ERROR missing type parameter name */ ~t|t] t