diff --git a/decoder.go b/decoder.go index 02759c0..0cd1e79 100644 --- a/decoder.go +++ b/decoder.go @@ -451,6 +451,10 @@ func (d *decoder) decodeStruct(name string, raw ast.Node, result reflect.Value) // Create the field name and decode fieldName = fmt.Sprintf("%s.%s", name, fieldName) for _, elem := range elems { + if obj, ok := elem.(ast.ObjectNode); ok { + elem = obj.Elem[0].Value + } + if err := d.decode(fieldName, elem, field); err != nil { return err } diff --git a/hcl/parse.y b/hcl/parse.y index 153ce46..6a1ff21 100644 --- a/hcl/parse.y +++ b/hcl/parse.y @@ -130,7 +130,7 @@ block: | blockId block { obj := ast.ObjectNode{ - K: $2.Key(), + K: $1, Elem: []ast.AssignmentNode{$2}, } diff --git a/hcl/y.go b/hcl/y.go index 423ebf1..f5e3cd6 100644 --- a/hcl/y.go +++ b/hcl/y.go @@ -455,7 +455,7 @@ hcldefault: //line parse.y:131 { obj := ast.ObjectNode{ - K: hclS[hclpt-0].aitem.Key(), + K: hclS[hclpt-1].str, Elem: []ast.AssignmentNode{hclS[hclpt-0].aitem}, } diff --git a/test-fixtures/decode_policy.hcl b/test-fixtures/decode_policy.hcl index 7ed797b..5b185cc 100644 --- a/test-fixtures/decode_policy.hcl +++ b/test-fixtures/decode_policy.hcl @@ -11,5 +11,5 @@ key "foo/bar/" { } key "foo/bar/baz" { - polizy = "deny" + policy = "deny" }