From 21fa3c1b07b80009ccb9e478a531d39966853681 Mon Sep 17 00:00:00 2001 From: DevTaube <78918080+DevTaube@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:19:50 +0200 Subject: [PATCH] Fixed mistake in "Array.reverse" Fixed a mistake in the definition of "Array.reverse" that caused the function to unexpectedly panic when given an array with length 0. --- currant.js | 2 +- currant/defaults/arrays.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/currant.js b/currant.js index ae921aa..ffc8683 100644 --- a/currant.js +++ b/currant.js @@ -2713,7 +2713,7 @@ const CURRANT_STD_ARRAYS = ` itemType: fun = f@currantArrayItemType; reverse: fun = (src: arr) -> arr { - if(len(src) == 0u64, <- { -> [itemType(src): 0u64, 0u8]; }); + if(len(src) == 0u64, <- { -> [itemType(src): 0u64: none]; }); dest: arr = [itemType(src): len(src): src[0u64]]; for(range(0u64, len(src)), (i: u64) -> lpa { dest[len(src) - 1u64 - i] = src[i]; diff --git a/currant/defaults/arrays.js b/currant/defaults/arrays.js index b62cdeb..20f3f43 100644 --- a/currant/defaults/arrays.js +++ b/currant/defaults/arrays.js @@ -6,7 +6,7 @@ const CURRANT_STD_ARRAYS = ` itemType: fun = f@currantArrayItemType; reverse: fun = (src: arr) -> arr { - if(len(src) == 0u64, <- { -> [itemType(src): 0u64, 0u8]; }); + if(len(src) == 0u64, <- { -> [itemType(src): 0u64: none]; }); dest: arr = [itemType(src): len(src): src[0u64]]; for(range(0u64, len(src)), (i: u64) -> lpa { dest[len(src) - 1u64 - i] = src[i];