Source file
test/fixedbugs/issue28748.go
1
2
3 package main
4
5 import (
6 "fmt"
7 "reflect"
8 "strings"
9 )
10
11
12
13
14
15 func main() {
16 defer func() {
17 e := recover()
18 if e == nil {
19 panic("should have panicked")
20 }
21 text := fmt.Sprintf("%s", e)
22 if !strings.HasPrefix(text, "reflect:") {
23 panic("wanted a reflect error, got this instead:\n" + text)
24 }
25 }()
26 r := reflect.MakeFunc(reflect.TypeOf(func() error { return nil }),
27 func(args []reflect.Value) []reflect.Value {
28 var x [1]reflect.Value
29 return x[:]
30 }).Interface().(func() error)
31 r()
32 }
33
View as plain text