Closed pd closed 9 months ago
Related to https://github.com/CertainLach/jrsonnet/pull/117
Sorry, I should read properly first :D Yes, this is a bug.
This is due to unchecked conversion from f64
(all jsonnet numbers are f64
) to usize
using num as usize
, where negative numbers are rounded to zero, in array indexing implementation.
In jrsonnet, any negative index of a non-empty array returns the first element. In go-jsonnet, it is an out-of-bounds error.
jrsonnet:
go-jsonnet on the same file:
Negative index on an empty array does fail, but with the wrong index value:
jrsonnet:
go-jsonnet: