Skip to content

Commit

Permalink
Add shadow suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed May 22, 2024
1 parent f3f08c2 commit 7dc1f11
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/check_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,11 @@ gb_internal Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, O
} else {
error(lhs->expr, "Cannot assign to '%s' which is a procedure parameter", str);
}
error_line("\tSuggestion: Did you mean to pass '%.*s' by pointer?\n", LIT(e->token.string));
if (is_type_pointer(e->type)) {
error_line("\tSuggestion: Did you mean to shadow it? '%.*s := %.*s'?\n", LIT(e->token.string), LIT(e->token.string));
} else {
error_line("\tSuggestion: Did you mean to pass '%.*s' by pointer?\n", LIT(e->token.string));
}
show_error_on_line(e->token.pos, token_pos_end(e->token));
} else {
ERROR_BLOCK();
Expand Down

0 comments on commit 7dc1f11

Please sign in to comment.