Skip to content

Commit 2d24b44

Browse files
committed
BAD Try to show pointer error message on normal proc call
Like other PRS: - odin-lang#5817 - odin-lang#5818 But for the non-proc-group, non-polymorphic proc-calls.
1 parent 4b8751b commit 2d24b44

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/check_expr.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6495,11 +6495,29 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
64956495
} else {
64966496
if (show_error) {
64976497
check_assignment(c, o, param_type, str_lit("procedure argument"));
6498+
gbString pts = type_to_string(param_type);
6499+
gbString ots = type_to_string(o->type, true);
6500+
defer (gb_string_free(pts));
6501+
defer (gb_string_free(ots));
6502+
if (pts[0] == '^' && pts[0] != ots[0]){
6503+
gbString os = expr_to_string(o->expr);
6504+
defer (gb_string_free(os));
6505+
error_line("\tSuggestion: Try passing the pointer instead of the value with '&%s'\n", os);
6506+
}
64986507
}
64996508
err = CallArgumentError_WrongTypes;
65006509
}
65016510
} else if (show_error) {
65026511
check_assignment(c, o, param_type, str_lit("procedure argument"));
6512+
// gbString pts = type_to_string(param_type);
6513+
// gbString ots = type_to_string(o->type, true);
6514+
// defer (gb_string_free(pts));
6515+
// defer (gb_string_free(ots));
6516+
// if (pts[0] == '^' && pts[0] != ots[0]){
6517+
// gbString os = expr_to_string(o->expr);
6518+
// defer (gb_string_free(os));
6519+
// error_line("\tSuggestion: Try passing the pointer instead of the value with '&%s'\n", os);
6520+
// }
65036521
}
65046522

65056523
if (e && e->flags & EntityFlag_ConstInput) {

0 commit comments

Comments
 (0)