Source file
test/typeparam/issue51521.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "fmt"
11 "strings"
12 )
13
14 type I interface{ M() }
15
16 func F[P I](p P) { defer catch(); p.M() }
17 func G[T any]() { defer catch(); interface{ M() T }.M(nil) }
18
19 func main() {
20 F[I](nil)
21 G[int]()
22 }
23
24 func catch() {
25 err := recover()
26 if err, ok := err.(error); ok && strings.Contains(err.Error(), "nil pointer dereference") {
27 return
28 }
29 fmt.Println("FAIL", err)
30 }
31
View as plain text