funcs/lang lookup: validate that argument is map or object type
This commit is contained in:
parent
c06f24b323
commit
4ec904bca7
|
@ -508,9 +508,11 @@ var LookupFunc = function.New(&function.Spec{
|
|||
// return the default type
|
||||
return args[2].Type(), nil
|
||||
}
|
||||
return cty.DynamicPseudoType, nil
|
||||
default:
|
||||
return cty.DynamicPseudoType, fmt.Errorf("the given object has no attribute %q", key)
|
||||
case ty.IsMapType():
|
||||
return ty.ElementType(), nil
|
||||
default:
|
||||
return cty.NilType, fmt.Errorf("lookup() requires a map as the first argument")
|
||||
}
|
||||
},
|
||||
Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {
|
||||
|
|
Loading…
Reference in New Issue