From e84055c158222c4340758097569dc1011182cccf Mon Sep 17 00:00:00 2001 From: ~hedy Date: Mon, 12 Aug 2024 14:01:27 +0800 Subject: [PATCH 1/2] Handle negative index in `Index` --- src/prelude.cog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/prelude.cog b/src/prelude.cog index 4843038..06ef696 100644 --- a/src/prelude.cog +++ b/src/prelude.cog @@ -215,6 +215,8 @@ Def Index ( Let N be Integer!; Let L be List!; + When < 0 N ( Error Join "Invalid index " Show N ); + Do If Zero? N ( return First element of L ) else ( When Empty? L ( Error "Index is beyond end of list" ); From bc47e144418f90ffc15ce1f701f0b9bc5dc7b24d Mon Sep 17 00:00:00 2001 From: Finn Barber Date: Thu, 15 Aug 2024 12:07:21 +0100 Subject: [PATCH 2/2] Highlight the backtrace functions in red --- src/runtime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime.h b/src/runtime.h index f1ed51a..2f716ef 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -608,7 +608,7 @@ static void print_backtrace(int n, const backtrace* b, int last_spaces) } fputs("\033[0m", stderr); } - fprintf(stderr, "\033[0;2m%s\033[0m %.*s\033[0;1m%.*s\033[0m%s\n", + fprintf(stderr, "\033[0;2m%s\033[0m %.*s\033[31;1m%.*s\033[0m%s\n", pos, (int)(col - len - 1), ln, len, ln + col - len - 1,