aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-03-18 15:18:10 +0000
committergingerBill <bill@gingerbill.org>2024-03-18 15:18:10 +0000
commit009b6f44e379e7644e0f2987663d52186dea5656 (patch)
treef4fcb4c61dd50e3adf70e7b493b3aa6ec499eab1
parentebd3065aa2806118f1f0868eb633edb72c230aa5 (diff)
Add loads of checks for common mistakes for C programmer
-rw-r--r--src/check_expr.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index bea204e2b..b58006427 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -1539,7 +1539,25 @@ gb_internal Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *nam
if (is_blank_ident(name)) {
error(n, "'_' cannot be used as a value");
} else {
+ ERROR_BLOCK();
error(n, "Undeclared name: %.*s", LIT(name));
+
+ // NOTE(bill): Loads of checks for C programmers
+ if (name == "float") {
+ error_line("\tSuggestion: Did you mean 'f32'?\n");
+ } else if (name == "double") {
+ error_line("\tSuggestion: Did you mean 'f64'?\n");
+ } else if (name == "short") {
+ error_line("\tSuggestion: Did you mean 'i16' or 'c.short' (which is part of 'core:c')?\n");
+ } else if (name == "long") {
+ error_line("\tSuggestion: Did you mean 'c.long' (which is part of 'core:c')?\n");
+ } else if (name == "unsigned") {
+ error_line("\tSuggestion: Did you mean 'c.uint' (which is part of 'core:c')?\n");
+ } else if (name == "char") {
+ error_line("\tSuggestion: Did you mean 'u8', 'i8' or 'c.char' (which is part of 'core:c')?\n");
+ } else if (name == "while") {
+ error_line("\tSuggestion: Did you mean 'for'? Odin only has one loop construct: 'for'\n");
+ }
}
o->type = t_invalid;
o->mode = Addressing_Invalid;