lang/funcs: Don't panic when distinct called with empty list
This commit is contained in:
parent
8118bf8d93
commit
55794eb658
|
@ -363,6 +363,9 @@ var DistinctFunc = function.New(&function.Spec{
|
|||
}
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return cty.ListValEmpty(retType.ElementType()), nil
|
||||
}
|
||||
return cty.ListVal(list), nil
|
||||
},
|
||||
})
|
||||
|
|
|
@ -901,6 +901,11 @@ func TestDistinct(t *testing.T) {
|
|||
}),
|
||||
false,
|
||||
},
|
||||
{
|
||||
cty.ListValEmpty(cty.String),
|
||||
cty.ListValEmpty(cty.String),
|
||||
false,
|
||||
},
|
||||
{
|
||||
cty.ListVal([]cty.Value{
|
||||
cty.StringVal("a"),
|
||||
|
|
Loading…
Reference in New Issue