checker: suggest ..[]T when passing a slice to variadic arg ..T

This commit is contained in:
Laytan Laats
2023-11-14 16:53:30 +01:00
parent 70c1f9d0e1
commit 9e5e49a65d

View File

@@ -5652,6 +5652,14 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
} else {
if (show_error) {
check_assignment(c, o, param_type, str_lit("procedure argument"));
Type *src = base_type(o->type);
Type *dst = base_type(param_type);
if (is_type_slice(src) && are_types_identical(src->Slice.elem, dst)) {
gbString a = expr_to_string(o->expr);
error_line("\tSuggestion: Did you mean to pass the slice into the variadic parameter with ..%s?\n\n", a);
gb_string_free(a);
}
}
err = CallArgumentError_WrongTypes;
}