mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Improve error message for multi-valued global declarations not be allowed
This commit is contained in:
+2
-6
@@ -2860,12 +2860,8 @@ bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global) {
|
|||||||
return false;
|
return false;
|
||||||
} else if (is_global) {
|
} else if (is_global) {
|
||||||
Ast *n = vd->values[rhs-1];
|
Ast *n = vd->values[rhs-1];
|
||||||
isize total = get_total_value_count(vd->values);
|
error(n, "Expected %td expressions on the right hand side, got %td", lhs, rhs);
|
||||||
if (total > rhs) {
|
error_line("Note: Global declarations do not allow for multi-valued expressions");
|
||||||
error(n, "Global declarations do not allow for multi-valued expressions. Expected %td expressions on the right hand side, got %td", lhs, rhs);
|
|
||||||
} else {
|
|
||||||
error(n, "Expected %td expressions on the right hand side, got %td", lhs, rhs);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -2835,7 +2835,12 @@ Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup *docs) {
|
|||||||
|
|
||||||
if (f->curr_proc == nullptr) {
|
if (f->curr_proc == nullptr) {
|
||||||
if (values.count > 0 && names.count != values.count) {
|
if (values.count > 0 && names.count != values.count) {
|
||||||
syntax_error(values[0], "Expected %td expressions on the right hand side, got %td", names.count, values.count);
|
syntax_error(
|
||||||
|
values[0],
|
||||||
|
"Expected %td expressions on the right hand side, got %td\n"
|
||||||
|
"\tNote: Global declarations do not allow for multi-valued expressions",
|
||||||
|
names.count, values.count
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user