diff options
| author | gingerBill <bill@gingerbill.org> | 2024-05-03 14:22:30 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-05-03 14:22:30 +0100 |
| commit | f2505b096d7367e4a6aa66475cda81e9f9bc0dae (patch) | |
| tree | 31a1bff0e142cd86b99650a8c73aa81073de58cd /src/check_expr.cpp | |
| parent | 242307dd4466389e971b6273c1267708777b50dd (diff) | |
Improve error message's suggestion for `if !integer`
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 06d0a8b12..83706112b 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1802,11 +1802,13 @@ gb_internal bool check_unary_op(CheckerContext *c, Operand *o, Token op) { case Token_Not: if (!is_type_boolean(type) || is_type_array_like(o->type)) { ERROR_BLOCK(); - str = expr_to_string(o->expr); error(op, "Operator '%.*s' is only allowed on boolean expressions", LIT(op.string)); - gb_string_free(str); if (is_type_integer(type)) { - error_line("\tSuggestion: Did you mean to use the bitwise not operator '~'?\n"); + str = expr_to_string(o->expr); + error_line("\tSuggestion: Did you mean to do one of the following?\n"); + error_line("\t\t'%s == 0'?\n", str); + error_line("\t\tUse of the bitwise not operator '~'?\n"); + gb_string_free(str); } } else { o->type = t_untyped_bool; |