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:
parent
c9c2a2bd16
commit
446387109d
@ -64,7 +64,7 @@ func TestDecode(t *testing.T) {
|
||||
Required: true,
|
||||
},
|
||||
nil,
|
||||
cty.DynamicVal,
|
||||
cty.NullVal(cty.Number),
|
||||
1, // attribute "a" is required
|
||||
},
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user