From c83307f26f1978143056df1e8881a6b81897f0b5 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 10 Jul 2024 12:39:42 +0100 Subject: Give error message suggestion when doing `^x` instead of `x^` if `x` is an r-value --- src/check_type.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/check_type.cpp') diff --git a/src/check_type.cpp b/src/check_type.cpp index cd329af00..dd8559114 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -3337,6 +3337,10 @@ gb_internal bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, T gbString s = expr_to_string(pt->type); error(e, "^ is used for pointer types, did you mean '&%s'?", s); gb_string_free(s); + } else if (is_type_pointer(o.type)) { + gbString s = expr_to_string(pt->type); + error(e, "^ is used for pointer types, did you mean a dereference: '%s^'?", s); + gb_string_free(s); } else { // NOTE(bill): call check_type_expr again to get a consistent error message elem = check_type_expr(&c, pt->type, nullptr); -- cgit v1.2.3