From: Brendan Hansen Date: Sat, 28 Aug 2021 15:21:36 +0000 (-0500) Subject: tabs are now supported by error message reporting X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=22eff910e942773c629c83bc9526b54dc6ad3e96;p=onyx.git tabs are now supported by error message reporting --- diff --git a/bin/onyx b/bin/onyx index fa6b43e5..3bcc2ba0 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/docs/bugs b/docs/bugs index 1b0fdabc..4b26b29e 100644 --- a/docs/bugs +++ b/docs/bugs @@ -1,7 +1,22 @@ List of known bugs: [ ] macros are not allowed at the expression level. This is not necessarily a bug, but does - bring many complications to the table about how resolve this. + bring many complications to the table about how resolve this. Current solution is to + turn expression macros (macros that specify a return value) into a `do` expression. + +[ ] Enums suck. Make them more powerful. + +[ ] add `do` expressions: + + x := do { + a := 1; + b := 2; + return a + b; + }; + +[X] Add support for tabs in error messages. + +[ ] switch statements should work with any type that supports '=='. [X] recursive quick-procedures / procedures that use #auto have trouble if the first lexical return statement is a recursive call. diff --git a/src/onyxerrors.c b/src/onyxerrors.c index 0dbffbe1..d6ad29cd 100644 --- a/src/onyxerrors.c +++ b/src/onyxerrors.c @@ -21,7 +21,9 @@ static void print_detailed_message(OnyxError* err, bh_file_contents* fc) { #endif i32 linelength = 0; + i32 first_char = 0; char* walker = err->pos.line_start; + while (*walker == ' ' || *walker == '\t') first_char++, linelength++, walker++; while (*walker != '\n') linelength++, walker++; if (colored_printing) bh_printf("\033[90m"); @@ -30,7 +32,9 @@ static void print_detailed_message(OnyxError* err, bh_file_contents* fc) { bh_printf("%b\n", err->pos.line_start, linelength); char* pointer_str = bh_alloc_array(global_scratch_allocator, char, linelength + numlen); - memset(pointer_str, ' ', linelength + numlen); + memset(pointer_str, ' ', numlen); + memcpy(pointer_str + numlen - 1, err->pos.line_start, first_char); + memset(pointer_str + first_char + numlen - 1, ' ', err->pos.column - first_char); memset(pointer_str + err->pos.column + numlen - 1, '~', err->pos.length - 1); pointer_str[err->pos.column + numlen - 2] = '^'; pointer_str[err->pos.column + numlen + err->pos.length - 1] = 0;