Description
std.removeAt crashes with an internal panic instead of reporting a regular runtime error when the index is out of bounds, for both positive and negative indices.
Reproduction
std.removeAt([1, 2, 3], 5)
Actual (go-jsonnet v0.22.0, Homebrew CLI):
INTERNAL ERROR: (CRASH) runtime error: slice bounds out of range [:5] with capacity 3
goroutine 1 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x64
github.com/google/go-jsonnet.(*VM).Evaluate.func1()
github.com/google/go-jsonnet/vm.go:193 +0x34
...
github.com/google/go-jsonnet.builtinRemoveAt(...)
Same crash with a negative index:
std.removeAt([1, 2, 3], -1)
INTERNAL ERROR: (CRASH) runtime error: slice bounds out of range [:-1]
Expected
A regular runtime error consistent with the bounds errors used elsewhere, e.g. what plain indexing reports for the same indices:
RUNTIME ERROR: Index 5 out of bounds, not within [0, 3)
Notes
- sjsonnet reports a clean runtime error for both cases (
idx 5 out of bounds, array length 3).
- Found while differential-testing sjsonnet against go-jsonnet.
Description
std.removeAtcrashes with an internal panic instead of reporting a regular runtime error when the index is out of bounds, for both positive and negative indices.Reproduction
Actual (go-jsonnet v0.22.0, Homebrew CLI):
Same crash with a negative index:
Expected
A regular runtime error consistent with the bounds errors used elsewhere, e.g. what plain indexing reports for the same indices:
Notes
idx 5 out of bounds, array length 3).