1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00

allow conversion from [u]int* to float

This commit is contained in:
Conrad Pankoff 2018-11-05 07:40:16 +11:00
parent 0f57984957
commit 3ef5863438

View File

@ -264,6 +264,8 @@ func (self *_runtime) convertNumeric(v Value, t reflect.Type) reflect.Value {
panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would overflow", val.Type(), t)))
}
return val.Convert(t)
case reflect.Float32, reflect.Float64:
return val.Convert(t)
}
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
@ -279,10 +281,12 @@ func (self *_runtime) convertNumeric(v Value, t reflect.Type) reflect.Value {
panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would overflow", val.Type(), t)))
}
return val.Convert(t)
case reflect.Float32, reflect.Float64:
return val.Convert(t)
}
}
panic(self.panicTypeError(fmt.Sprintf("unsupported type %v for numeric conversion", val.Type())))
panic(self.panicTypeError(fmt.Sprintf("unsupported type %v -> %v for numeric conversion", val.Type(), t)))
}
func fieldIndexByName(t reflect.Type, name string) []int {