Skip to content

Commit

Permalink
Be very particular with the cases for the error notes
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed May 22, 2024
1 parent 2f35ee9 commit f3f08c2
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/check_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,29 +1193,28 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ
Type *y = dst;
bool same_inputs = are_types_identical_internal(x->Proc.params, y->Proc.params, false);
bool same_outputs = are_types_identical_internal(x->Proc.results, y->Proc.results, false);
if (same_inputs && same_outputs) {
if (x->Proc.calling_convention != y->Proc.calling_convention) {
gbString s_expected = type_to_string(y);
gbString s_got = type_to_string(x);

error_line("\tNote: The calling conventions differ between the procedure signature types\n");
error_line("\t Expected \"%s\", got \"%s\"\n",
proc_calling_convention_strings[y->Proc.calling_convention],
proc_calling_convention_strings[x->Proc.calling_convention]);
error_line("\t Expected: %s\n", s_expected);
error_line("\t Got: %s\n", s_got);
gb_string_free(s_got);
gb_string_free(s_expected);
}
} else if (same_inputs) {
if (same_inputs && same_outputs &&
x->Proc.calling_convention != y->Proc.calling_convention) {
gbString s_expected = type_to_string(y);
gbString s_got = type_to_string(x);

error_line("\tNote: The calling conventions differ between the procedure signature types\n");
error_line("\t Expected \"%s\", got \"%s\"\n",
proc_calling_convention_strings[y->Proc.calling_convention],
proc_calling_convention_strings[x->Proc.calling_convention]);
error_line("\t Expected: %s\n", s_expected);
error_line("\t Got: %s\n", s_got);
gb_string_free(s_got);
gb_string_free(s_expected);
} else if (same_inputs && !same_outputs) {
gbString s_expected = type_to_string(y->Proc.results);
gbString s_got = type_to_string(x->Proc.results);
error_line("\tNote: The return types differ between the procedure signature types\n");
error_line("\t Expected: %s\n", s_expected);
error_line("\t Got: %s\n", s_got);
gb_string_free(s_got);
gb_string_free(s_expected);
} else if (same_outputs) {
} else if (!same_inputs && same_outputs) {
gbString s_expected = type_to_string(y->Proc.params);
gbString s_got = type_to_string(x->Proc.params);
error_line("\tNote: The input parameter types differ between the procedure signature types\n");
Expand Down

0 comments on commit f3f08c2

Please sign in to comment.