Closed runsisi closed 1 month ago
thanks @runsisi, that sounds right. do you want to open the PR for this one?
There's value.CanInterface
couldn't we use that before calling value.Interface
since calling IsNil
can also panic if called on the wrong type?
sorry for the wrong hint, the actual panic occurs in type conversion:
var value interface{}
if p.typ.IsPointerType() {
value = reflect.ValueOf(p.obj).Elem().FieldByName(name).Interface()
} else {
value = reflect.ValueOf(p.obj).FieldByName(name).Interface()
}
result, err := conv.From(value) // <--- here
https://github.com/risor-io/risor/blob/v1.6.0/object/proxy.go#L86
func (c *PointerConverter) From(obj interface{}) (Object, error) {
v := reflect.ValueOf(obj).Elem().Interface() // <--- here
return c.valueConverter.From(v)
}
https://github.com/risor-io/risor/blob/v1.6.0/object/typeconv.go#L972
the code above panics:
maybe we should add
IsNil
check onFieldByName(name)
and returnobject.Nil
if it is true ^1?