Skip to content

Commit b562069

Browse files
committed
On wrong append call, help users pass-by-pointer
WHY? First Odin users that try to use append often forget to pass a pointer, and pass-by-value. This is a first attempt at helping with that, but a better version would be a generic way to check when any proc values should be pass-by-pointer instead of pass-by-value, as discussed at https://forum.odin-lang.org/t/least-parsable-most-common-error-message/1241/3
1 parent 4b8751b commit b562069

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/check_expr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7283,6 +7283,10 @@ gb_internal CallArgumentData check_call_arguments_proc_group(CheckerContext *c,
72837283
error_line("\tNo given arguments\n");
72847284
} else {
72857285
print_argument_types();
7286+
const gbString append_proc_name = gb_string_make(temporary_allocator(), "append");
7287+
if(gb_string_are_equal(expr_name, append_proc_name)){
7288+
error_line("Help: Make sure that you passed, as the first argument, a dynamic array by pointer, like so `append(&some_dynamic_array, ...)`.\n");
7289+
}
72867290
}
72877291

72887292
if (procs.count == 0) {

0 commit comments

Comments
 (0)