Skip to content

Commit

Permalink
function/stdlib: flatten no longer treats null values as unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
jbardin committed Jul 6, 2021
1 parent 55b3bcf commit 1712101
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cty/function/stdlib/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func flattener(flattenList cty.Value) ([]cty.Value, []cty.ValueMarks, bool) {

// Any dynamic types could result in more collections that need to be
// flattened, so the type cannot be known.
if val.Type().Equals(cty.DynamicPseudoType) {
if val == cty.DynamicVal {
isKnown = false
}

Expand Down
33 changes: 33 additions & 0 deletions cty/function/stdlib/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,39 @@ func TestFlatten(t *testing.T) {
}),
"",
},
{
cty.TupleVal([]cty.Value{
cty.TupleVal([]cty.Value{
cty.StringVal("a"),
cty.StringVal("b"),
}),
cty.NullVal(cty.DynamicPseudoType),
cty.TupleVal([]cty.Value{
cty.StringVal("c"),
}),
}),
cty.TupleVal([]cty.Value{
cty.StringVal("a"),
cty.StringVal("b"),
cty.NullVal(cty.DynamicPseudoType),
cty.StringVal("c"),
}),
"",
},
{
cty.TupleVal([]cty.Value{
cty.TupleVal([]cty.Value{
cty.StringVal("a"),
cty.StringVal("b"),
}),
cty.DynamicVal,
cty.TupleVal([]cty.Value{
cty.StringVal("c"),
}),
}),
cty.UnknownVal(cty.DynamicPseudoType),
"",
},
}

for _, test := range tests {
Expand Down

0 comments on commit 1712101

Please sign in to comment.