Allow integers to be unmarshaled into floats (#841)

Co-authored-by: Marty <martin@windscribe.com>
This commit is contained in:
Marty
2023-02-09 18:02:25 +01:00
committed by GitHub
parent c4a2eef8a4
commit 9f5726004e
3 changed files with 14 additions and 6 deletions
+6 -1
View File
@@ -887,6 +887,11 @@ func init() {
}
func (d *decoder) unmarshalInteger(value *unstable.Node, v reflect.Value) error {
kind := v.Kind()
if kind == reflect.Float32 || kind == reflect.Float64 {
return d.unmarshalFloat(value, v)
}
i, err := parseInteger(value.Data)
if err != nil {
return err
@@ -894,7 +899,7 @@ func (d *decoder) unmarshalInteger(value *unstable.Node, v reflect.Value) error
var r reflect.Value
switch v.Kind() {
switch kind {
case reflect.Int64:
v.SetInt(i)
return nil