diff --git a/linter/internal/types/stdlib.go b/linter/internal/types/stdlib.go index 062d0085..6548fb21 100644 --- a/linter/internal/types/stdlib.go +++ b/linter/internal/types/stdlib.go @@ -143,6 +143,7 @@ func prepareStdlib(g *typeGraph) { "join": g.newSimpleFuncType(stringOrArray, "sep", "arr"), "lines": g.newSimpleFuncType(arrayOfString, "arr"), "flattenArrays": g.newSimpleFuncType(anyArrayType, "arrs"), + "reverse": g.newSimpleFuncType(anyArrayType, "arrs"), "sort": g.newFuncType(anyArrayType, []ast.Parameter{required("arr"), optional("keyF")}), "uniq": g.newFuncType(anyArrayType, []ast.Parameter{required("arr"), optional("keyF")}), "sum": g.newSimpleFuncType(numberType, "arr"), diff --git a/testdata/builtinReverse.linter.golden b/testdata/builtinReverse.linter.golden index a272b65d..e69de29b 100644 --- a/testdata/builtinReverse.linter.golden +++ b/testdata/builtinReverse.linter.golden @@ -1,10 +0,0 @@ -../testdata/builtinReverse:1:1-12 Indexed object has no field "reverse" - -std.reverse([1, 2]) - - -../testdata/builtinReverse:1:1-20 Called value must be a function, but it is assumed to be void - -std.reverse([1, 2]) - - diff --git a/testdata/builtinReverse_empty.linter.golden b/testdata/builtinReverse_empty.linter.golden index ccd6f6b0..e69de29b 100644 --- a/testdata/builtinReverse_empty.linter.golden +++ b/testdata/builtinReverse_empty.linter.golden @@ -1,10 +0,0 @@ -../testdata/builtinReverse_empty:1:1-12 Indexed object has no field "reverse" - -std.reverse([]) - - -../testdata/builtinReverse_empty:1:1-16 Called value must be a function, but it is assumed to be void - -std.reverse([]) - - diff --git a/testdata/builtinReverse_many.linter.golden b/testdata/builtinReverse_many.linter.golden index c6528d52..e69de29b 100644 --- a/testdata/builtinReverse_many.linter.golden +++ b/testdata/builtinReverse_many.linter.golden @@ -1,10 +0,0 @@ -../testdata/builtinReverse_many:1:1-12 Indexed object has no field "reverse" - -std.reverse(["hello", "my", "name", "is", "tester"]) - - -../testdata/builtinReverse_many:1:1-53 Called value must be a function, but it is assumed to be void - -std.reverse(["hello", "my", "name", "is", "tester"]) - - diff --git a/testdata/builtinReverse_not_array.linter.golden b/testdata/builtinReverse_not_array.linter.golden index d12c1aa1..e69de29b 100644 --- a/testdata/builtinReverse_not_array.linter.golden +++ b/testdata/builtinReverse_not_array.linter.golden @@ -1,10 +0,0 @@ -../testdata/builtinReverse_not_array:1:1-12 Indexed object has no field "reverse" - -std.reverse(false) - - -../testdata/builtinReverse_not_array:1:1-19 Called value must be a function, but it is assumed to be void - -std.reverse(false) - - diff --git a/testdata/builtinReverse_single.linter.golden b/testdata/builtinReverse_single.linter.golden index 2bd8dd7b..e69de29b 100644 --- a/testdata/builtinReverse_single.linter.golden +++ b/testdata/builtinReverse_single.linter.golden @@ -1,10 +0,0 @@ -../testdata/builtinReverse_single:1:1-12 Indexed object has no field "reverse" - -std.reverse(["hello"]) - - -../testdata/builtinReverse_single:1:1-23 Called value must be a function, but it is assumed to be void - -std.reverse(["hello"]) - - diff --git a/testdata/stdlib_smoke_test.golden b/testdata/stdlib_smoke_test.golden index 972ba97e..7bc0b661 100644 --- a/testdata/stdlib_smoke_test.golden +++ b/testdata/stdlib_smoke_test.golden @@ -162,6 +162,10 @@ 5 ], "repeat": "foofoofoo", + "reverse": [ + "a", + "b" + ], "rstripChars": "aaabbbb", "set": [ [ diff --git a/testdata/stdlib_smoke_test.jsonnet b/testdata/stdlib_smoke_test.jsonnet index de98c35f..8272a5fd 100644 --- a/testdata/stdlib_smoke_test.jsonnet +++ b/testdata/stdlib_smoke_test.jsonnet @@ -124,6 +124,7 @@ join: std.join(sep=",", arr=["a", "b", "c"]), lines: std.lines(arr=["a", "b", "c"]), flattenArrays: std.flattenArrays([[1], [2, 3], [4, 5, [6, 7]]]), + reverse: std.reverse(["b", "a"]), sort: [ std.sort([2, 3, 1]), std.sort(arr=[2, 3, 1], keyF=function(x) -x),