mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
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:
13
vendor/github.com/zclconf/go-cty/cty/function/stdlib/collection.go
generated
vendored
13
vendor/github.com/zclconf/go-cty/cty/function/stdlib/collection.go
generated
vendored
@ -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.
|
||||
|
Reference in New Issue
Block a user