From c02b1728df2b16f29aae3fccd650f24af141c7a8 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Fri, 30 Jan 2026 16:01:36 +0100 Subject: [PATCH] make linter aware of clamp function --- linter/internal/types/stdlib.go | 1 + linter/testdata/clamp.jsonnet | 1 + linter/testdata/clamp.linter.golden | 0 3 files changed, 2 insertions(+) create mode 100644 linter/testdata/clamp.jsonnet create mode 100644 linter/testdata/clamp.linter.golden diff --git a/linter/internal/types/stdlib.go b/linter/internal/types/stdlib.go index 6f0f4a91d..9d2146dfd 100644 --- a/linter/internal/types/stdlib.go +++ b/linter/internal/types/stdlib.go @@ -73,6 +73,7 @@ func prepareStdlib(g *typeGraph) { "acos": g.newSimpleFuncType(numberType, "x"), "atan": g.newSimpleFuncType(numberType, "x"), "round": g.newSimpleFuncType(numberType, "x"), + "clamp": g.newSimpleFuncType(numberType, "x", "min", "max"), // Assertions and debugging "assertEqual": g.newSimpleFuncType(boolType, "a", "b"), diff --git a/linter/testdata/clamp.jsonnet b/linter/testdata/clamp.jsonnet new file mode 100644 index 000000000..6abaf9b40 --- /dev/null +++ b/linter/testdata/clamp.jsonnet @@ -0,0 +1 @@ +std.clamp(100, 1, 10) \ No newline at end of file diff --git a/linter/testdata/clamp.linter.golden b/linter/testdata/clamp.linter.golden new file mode 100644 index 000000000..e69de29bb