tabs are now supported by error message reporting
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 28 Aug 2021 15:21:36 +0000 (10:21 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 28 Aug 2021 15:21:36 +0000 (10:21 -0500)
bin/onyx
docs/bugs
src/onyxerrors.c

index fa6b43e511e716384641ff219ee2e61e48a84a7e..3bcc2ba078bf9b5e67217cabfa112613f8d76cb9 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 1b0fdabc839f13f47066d5001b5f3ae15afbca81..4b26b29e34e41cea25c87686d049a8a33d330cfd 100644 (file)
--- 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.
index 0dbffbe1397d31325526f6d8c4c1ced35ae0f55c..d6ad29cd23675691f0ac9fe50310833fb2415448 100644 (file)
@@ -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;