mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Fix #3320
This commit is contained in:
+10
-9
@@ -1174,6 +1174,16 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ
|
|||||||
type_str, type_extra,
|
type_str, type_extra,
|
||||||
LIT(context_name));
|
LIT(context_name));
|
||||||
check_assignment_error_suggestion(c, operand, type);
|
check_assignment_error_suggestion(c, operand, type);
|
||||||
|
|
||||||
|
if (context_name == "procedure argument") {
|
||||||
|
Type *src = base_type(operand->type);
|
||||||
|
Type *dst = base_type(type);
|
||||||
|
if (is_type_slice(src) && are_types_identical(src->Slice.elem, dst)) {
|
||||||
|
gbString a = expr_to_string(operand->expr);
|
||||||
|
error_line("\tSuggestion: Did you mean to pass the slice into the variadic parameter with ..%s?\n\n", a);
|
||||||
|
gb_string_free(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5905,16 +5915,7 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
|
|||||||
s = assign_score_function(MAXIMUM_TYPE_DISTANCE);
|
s = assign_score_function(MAXIMUM_TYPE_DISTANCE);
|
||||||
} else {
|
} else {
|
||||||
if (show_error) {
|
if (show_error) {
|
||||||
ERROR_BLOCK();
|
|
||||||
check_assignment(c, o, param_type, str_lit("procedure argument"));
|
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;
|
err = CallArgumentError_WrongTypes;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user