Skip to content

Commit 42875ab

Browse files
inoaslpil
authored andcommitted
no-neg
1 parent 9cc2bf7 commit 42875ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/gleam_stdlib_decode_ffi.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export function index(data, key) {
1515

1616
const key_is_int = Number.isInteger(key);
1717

18-
// Only elements 0-7 of lists can be indexed
19-
if (key_is_int && key < 8 && data instanceof List) {
18+
// Only elements 0-7 of lists can be indexed, negative indices are not allowed
19+
if (key_is_int && key < 8 && key >= 0 && data instanceof List) {
2020
let i = 0;
2121
for (const value of data) {
2222
if (i === key) return new Ok(new Some(value));

0 commit comments

Comments
 (0)