github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/types/testdata/fixedbugs/issue59956.go (about) 1 // Copyright 2023 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 func f1(func(int)) 8 func f2(func(int), func(string)) 9 func f3(func(int), func(string), func(float32)) 10 11 func g1[P any](P) {} 12 13 func _() { 14 f1(g1) 15 f2(g1, g1) 16 f3(g1, g1, g1) 17 } 18 19 // More complex examples 20 21 func g2[P any](P, P) {} 22 func h3[P any](func(P), func(P), func() P) {} 23 func h4[P, Q any](func(P), func(P, Q), func() Q, func(P, Q)) {} 24 25 func r1() int { return 0 } 26 27 func _() { 28 h3(g1, g1, r1) 29 h4(g1, g2, r1, g2) 30 } 31 32 // Variadic cases 33 34 func f(func(int)) 35 func g[P any](P) {} 36 37 func d[P any](...func(P)) {} 38 39 func _() { 40 d /* ERROR "cannot infer P" */ () 41 d(f) 42 d(f, g) 43 d(f, g, g) 44 d /* ERROR "cannot infer P" */ (g, g, g) 45 d(g, g, f) 46 d(g, f, g, f) 47 }