Handle other key types in Unmarshal (#276)
Previously, this would fail with: ``` panic: reflect.Value.SetMapIndex: value of type string is not assignable to type toml.letter [recovered] panic: reflect.Value.SetMapIndex: value of type string is not assignable to type toml.letter ``` Now this only panics when the key type cannot be converted from a string.
This commit is contained in:
committed by
Thomas Pelletier
parent
1d8903f1d0
commit
728039f679
+1
-1
@@ -615,7 +615,7 @@ func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value,
|
||||
if err != nil {
|
||||
return mval, formatError(err, tval.GetPosition(key))
|
||||
}
|
||||
mval.SetMapIndex(reflect.ValueOf(key), mvalf)
|
||||
mval.SetMapIndex(reflect.ValueOf(key).Convert(mtype.Key()), mvalf)
|
||||
}
|
||||
}
|
||||
return mval, nil
|
||||
|
||||
Reference in New Issue
Block a user