Skip to content

Commit

Permalink
Fixed mistake in "Array.reverse"
Browse files Browse the repository at this point in the history
Fixed a mistake in the definition of "Array.reverse" that caused the function to unexpectedly panic when given an array with length 0.
  • Loading branch information
schwalbe-t authored Jan 24, 2023
1 parent 2f515c2 commit 21fa3c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion currant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion currant/defaults/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 21fa3c1

Please sign in to comment.