Source file
test/typeparam/issue45722.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "fmt"
11 "log"
12 )
13
14 func try[T any](v T, err error) T {
15 if err != nil {
16 panic(err)
17 }
18 return v
19 }
20
21 func handle(handle func(error)) {
22 if issue := recover(); issue != nil {
23 if e, ok := issue.(error); ok && e != nil {
24 handle(e)
25 } else {
26 handle(fmt.Errorf("%v", e))
27 }
28 }
29 }
30
31 func main() {
32 defer handle(func(e error) { log.Fatalln(e) })
33 _ = try(fmt.Print(""))
34 }
35
View as plain text