Don't allow nulls in calls to merge

This commit is contained in:
Pam Selle 2019-06-14 14:54:51 -04:00
parent 9f387902fa
commit 1255ad6722
2 changed files with 11 additions and 1 deletions

View File

@ -876,7 +876,6 @@ var MergeFunc = function.New(&function.Spec{
Name: "maps", Name: "maps",
Type: cty.DynamicPseudoType, Type: cty.DynamicPseudoType,
AllowDynamicType: true, AllowDynamicType: true,
AllowNull: true,
}, },
Type: function.StaticReturnType(cty.DynamicPseudoType), Type: function.StaticReturnType(cty.DynamicPseudoType),
Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) { Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {

View File

@ -2045,6 +2045,17 @@ func TestMerge(t *testing.T) {
cty.NilVal, cty.NilVal,
true, true,
}, },
{ // argument error, for a null type
[]cty.Value{
cty.MapVal(map[string]cty.Value{
"a": cty.StringVal("b"),
}),
cty.NullVal(cty.String),
},
cty.NilVal,
true,
},
{ // merge maps of maps { // merge maps of maps
[]cty.Value{ []cty.Value{
cty.MapVal(map[string]cty.Value{ cty.MapVal(map[string]cty.Value{