aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-03-20 13:28:17 +0000
committergingerBill <bill@gingerbill.org>2024-03-20 13:28:17 +0000
commitb1dae2d59ab1f35992d0f24b4f01d4d2123f9262 (patch)
tree266e9f1abeb5fabf4738f207d6159091b22217ef /src/check_expr.cpp
parent1514d6496447506f7d8f43168a36147f9007b0d2 (diff)
Add `x: T; y: ^T = x` suggestion to do `&x`
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index e9a6f5122..e22d57814 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -2248,6 +2248,12 @@ gb_internal void check_assignment_error_suggestion(CheckerContext *c, Operand *o
gbString s = expr_to_string(c->type_hint_expr);
error_line("\tSuggestion: make sure that `%s` is attached to the compound literal directly\n", s);
gb_string_free(s);
+ } else if (is_type_pointer(type) &&
+ o->mode == Addressing_Variable &&
+ are_types_identical(type_deref(type), o->type)) {
+ gbString s = expr_to_string(o->expr);
+ error_line("\tSuggestion: Did you mean `&%s`\n", s);
+ gb_string_free(s);
}
}