govendor fetch github.com/hashicorp/hcl@99e2f22

This commit is contained in:
Lang Martin
2019-04-25 16:35:31 -04:00
parent 6abbf6a1c3
commit c8fd0be03c
2 changed files with 11 additions and 10 deletions

View File

@@ -404,20 +404,21 @@ func (d *decoder) decodeMap(name string, node ast.Node, result reflect.Value) er
}
func (d *decoder) decodePtr(name string, node ast.Node, result reflect.Value) error {
// lookup the concrete (non pointer) type and decode into that
// if the pointer is nil, create an element of the type and set the pointer to that
resultType := result.Type()
val := reflect.Indirect(result)
if val.Kind() == reflect.Invalid || val == reflect.Zero(resultType) {
resultElemType := resultType.Elem()
val = reflect.New(resultElemType)
result.Set(val)
// if pointer is not nil, decode into existing value
if !result.IsNil() {
return d.decode(name, node, result.Elem())
}
// Create an element of the concrete (non pointer) type and decode
// into that. Then set the value of the pointer to this type.
resultType := result.Type()
resultElemType := resultType.Elem()
val := reflect.New(resultElemType)
if err := d.decode(name, node, reflect.Indirect(val)); err != nil {
return err
}
result.Set(val)
return nil
}
@@ -516,7 +517,7 @@ func expandObject(node ast.Node, result reflect.Value) ast.Node {
// we need to un-flatten the ast enough to decode
newNode := &ast.ObjectItem{
Keys: []*ast.ObjectKey{
&ast.ObjectKey{
{
Token: keyToken,
},
},