1// errorcheck -G 2 3// Copyright 2020 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7// Basic type parameter list type-checking (not syntax) errors. 8 9package tparam1 10 11// The predeclared identifier "any" may be used in place of interface{}. 12var _ any 13 14func _(_ any) 15 16type _[_ any] struct{} 17 18const N = 10 19 20type ( 21 _ []struct{} // slice 22 _ [N]struct{} // array 23 _[T any] struct{} 24 _[T, T any] struct{} // ERROR "T redeclared" 25 _[T1, T2 any, T3 any] struct{} 26) 27 28func _[T any]() {} 29func _[T, T any]() {} // ERROR "T redeclared" 30func _[T1, T2 any](x T1) T2 { panic(0) } 31 32// Type parameters are visible from opening [ to end of function. 33type C interface{} 34 35func _[T interface{}]() {} 36func _[T C]() {} 37func _[T struct{}]() {} // ok if #48424 is accepted 38func _[T interface{ m() T }]() {} 39func _[T1 interface{ m() T2 }, T2 interface{ m() T1 }]() { 40 var _ T1 41} 42 43// TODO(gri) expand this 44