vendor: github.com/zclconf/go-cty v1.16.0

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-01-13 18:00:34 +01:00
parent 26026810fe
commit 66ecb53fa7
8 changed files with 38 additions and 28 deletions

View File

@ -147,12 +147,6 @@ var ElementFunc = function.New(&function.Spec{
},
Type: func(args []cty.Value) (cty.Type, error) {
list := args[0]
index := args[1]
if index.IsKnown() {
if index.LessThan(cty.NumberIntVal(0)).True() {
return cty.DynamicPseudoType, fmt.Errorf("cannot use element function with a negative index")
}
}
listTy := list.Type()
switch {
@ -189,10 +183,6 @@ var ElementFunc = function.New(&function.Spec{
return cty.DynamicVal, fmt.Errorf("invalid index: %s", err)
}
if args[1].LessThan(cty.NumberIntVal(0)).True() {
return cty.DynamicVal, fmt.Errorf("cannot use element function with a negative index")
}
input, marks := args[0].Unmark()
if !input.IsKnown() {
return cty.UnknownVal(retType), nil
@ -203,6 +193,9 @@ var ElementFunc = function.New(&function.Spec{
return cty.DynamicVal, errors.New("cannot use element function with an empty list")
}
index = index % l
if index < 0 {
index += l
}
// We did all the necessary type checks in the type function above,
// so this is guaranteed not to fail.