aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-05-23 11:50:05 +0100
committergingerBill <bill@gingerbill.org>2022-05-23 11:50:05 +0100
commitd9f293b2818b30ebe2d29180aa62c3ce432c4582 (patch)
tree71d3d6a04966c71a9b838f94a8004b1b6db605d7 /src/check_expr.cpp
parent8c1499dbc2a7d32c7dba12cd9d3c93c51411d373 (diff)
Add better error message for trying to dereference a multi-pointer
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index bc28583b7..013d22913 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -9310,7 +9310,15 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
} else {
gbString str = expr_to_string(o->expr);
gbString typ = type_to_string(o->type);
+ begin_error_block();
+
error(o->expr, "Cannot dereference '%s' of type '%s'", str, typ);
+ if (o->type && is_type_multi_pointer(o->type)) {
+ error_line("\tDid you mean '%s[0]'?\n", str);
+ }
+
+ end_error_block();
+
gb_string_free(typ);
gb_string_free(str);
o->mode = Addressing_Invalid;