Source file
test/fixedbugs/issue59338.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 func main() {
13 var f1 func(int) int
14 f1 = g1
15 if f1(1) != g1(1) {
16 panic(1)
17 }
18
19 var f2 func(int) string = g2
20 if f2(2) != "" {
21 panic(2)
22 }
23
24 if g3(g1, 3) != g1(3) {
25 panic(3)
26 }
27
28 if g4(g2, 4) != "" {
29 panic(4)
30 }
31 }
32
33 func g1[P any](x P) P { return x }
34 func g2[P, Q any](x P) Q { var q Q; return q }
35
36 func g3(f1 func(int) int, x int) int { return f1(x) }
37 func g4(f2 func(int) string, x int) string { return f2(x) }
38
View as plain text