aboutsummaryrefslogtreecommitdiff
path: root/src/check_stmt.cpp
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-14 16:50:28 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-14 18:28:47 -0400
commitd4e2fa037797c026a1b7803f1514a87792af8888 (patch)
tree3f68e3fae99af5aaabb3101e162fa4673bd4da2a /src/check_stmt.cpp
parent582154f20d44ebf724301316e8cf27b1c768b7ee (diff)
Refactor `show_error_on_line`
This should adequately solve any issues with Unicode alignment by sidestepping the issue entirely. With this change, we make use of the built-in ANSI facilities of the terminal to underline the text. If the terminal does not support underlining, there are still the fallback bold markers at the start and end of error locations.
Diffstat (limited to 'src/check_stmt.cpp')
-rw-r--r--src/check_stmt.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index f2e3b0242..c369ba098 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -582,28 +582,20 @@ gb_internal Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, O
isize offset = show_error_on_line(e->token.pos, token_pos_end(e->token));
if (offset < 0) {
if (is_type_map(e->type)) {
- error_line("\tSuggestion: Did you mean? 'for key, &%.*s in ...'\n", LIT(e->token.string));
+ error_line("\t\tSuggestion: Did you mean? 'for key, &%.*s in ...'\n", LIT(e->token.string));
} else {
- error_line("\tSuggestion: Did you mean? 'for &%.*s in ...'\n", LIT(e->token.string));
+ error_line("\t\tSuggestion: Did you mean? 'for &%.*s in ...'\n", LIT(e->token.string));
}
} else {
- error_line("\t");
- for (isize i = 0; i < offset-1; i++) {
- error_line(" ");
- }
- error_line("'%.*s' is immutable, declare it as '&%.*s' to make it mutable\n", LIT(e->token.string), LIT(e->token.string));
+ error_line("\t\t'%.*s' is immutable, declare it as '&%.*s' to make it mutable\n", LIT(e->token.string), LIT(e->token.string));
}
} else if (e && e->flags & EntityFlag_SwitchValue) {
isize offset = show_error_on_line(e->token.pos, token_pos_end(e->token));
if (offset < 0) {
- error_line("\tSuggestion: Did you mean? 'switch &%.*s in ...'\n", LIT(e->token.string));
+ error_line("\t\tSuggestion: Did you mean? 'switch &%.*s in ...'\n", LIT(e->token.string));
} else {
- error_line("\t");
- for (isize i = 0; i < offset-1; i++) {
- error_line(" ");
- }
- error_line("'%.*s' is immutable, declare it as '&%.*s' to make it mutable\n", LIT(e->token.string), LIT(e->token.string));
+ error_line("\t\t'%.*s' is immutable, declare it as '&%.*s' to make it mutable\n", LIT(e->token.string), LIT(e->token.string));
}
}
}