zcldec: AttrSpec should return null for missing attributes

Previously it was returning DynamicVal, but that's incorrect since it
would mean that even an otherwise-complete result that has an unpopulated
optional attribute would include an unknown.
This commit is contained in:
Martin Atkins 2017-06-04 13:05:35 -07:00
parent c9c2a2bd16
commit 446387109d
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ func TestDecode(t *testing.T) {
Required: true,
},
nil,
cty.DynamicVal,
cty.NullVal(cty.Number),
1, // attribute "a" is required
},

View File

@ -165,7 +165,7 @@ func (s *AttrSpec) decode(content *zcl.BodyContent, block *zcl.Block, ctx *zcl.E
if !exists {
// We don't need to check required and emit a diagnostic here, because
// that would already have happened when building "content".
return cty.DynamicVal, nil
return cty.NullVal(s.Type), nil
}
// TODO: Also try to convert the result value to s.Type