encoder: inline tables create map in nil interface (#496)
Co-authored-by: Thomas Pelletier <pelletier.thomas@gmail.com>
This commit is contained in:
+3
-5
@@ -120,11 +120,7 @@ func (d *decoder) fromParser(p *parser, v interface{}) error {
|
||||
// looks like a table. Otherwise the information
|
||||
// of a table is lost, and marshal cannot do the
|
||||
// round trip.
|
||||
v := current.get()
|
||||
if v.Kind() == reflect.Interface && v.IsNil() {
|
||||
newElement := reflect.MakeMap(mapStringInterfaceType)
|
||||
current.set(newElement)
|
||||
}
|
||||
ensureMapIfInterface(current)
|
||||
}
|
||||
case ast.ArrayTable:
|
||||
current, found, err = d.scopeWithArrayTable(root, node.Key())
|
||||
@@ -381,6 +377,8 @@ func unmarshalFloat(x target, node ast.Node) error {
|
||||
func (d *decoder) unmarshalInlineTable(x target, node ast.Node) error {
|
||||
assertNode(ast.InlineTable, node)
|
||||
|
||||
ensureMapIfInterface(x)
|
||||
|
||||
it := node.Children()
|
||||
for it.Next() {
|
||||
n := it.Node()
|
||||
|
||||
Reference in New Issue
Block a user