You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import "reflect"
func main() {
r := reflect.MakeFunc(reflect.TypeOf(func() error { return nil }),
func(args []reflect.Value) []reflect.Value {
var x [1]reflect.Value
return x[:]
}).Interface().(func() error)
r()
}
This code will cause the r() call to panic with a nil pointer dereference. We should really panic with something sensible instead.
The code is trying to provide a sensible panic, but panics when trying to build that panic message. It gets to here:
if v.typ != typ {
panic("reflect: function created by MakeFunc using " + funcName(f) +
" returned wrong type: have " +
out[i].typ.String() + " for " + typ.String())
}
But v.typ is nil, so out[i].typ.String() (v and out[i] are the same) panics inside (*rtype).String.
This has been the case since at least go 1.2. Marking for 1.13.
The text was updated successfully, but these errors were encountered:
This code will cause the
r()
call to panic with a nil pointer dereference. We should reallypanic
with something sensible instead.The code is trying to provide a sensible panic, but panics when trying to build that panic message. It gets to here:
But
v.typ
is nil, soout[i].typ.String()
(v
andout[i]
are the same) panics inside(*rtype).String
.This has been the case since at least go 1.2. Marking for 1.13.
The text was updated successfully, but these errors were encountered: