From 1fd1203d8bf1977366dbf1f366623924e5c3e5c0 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 12 Sep 2020 16:04:02 +0100 Subject: [PATCH] Improve error message for multi-valued global declarations not be allowed --- src/checker.cpp | 8 ++------ src/parser.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/checker.cpp b/src/checker.cpp index ca364d6c1..7659a42ff 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2860,12 +2860,8 @@ bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global) { return false; } else if (is_global) { Ast *n = vd->values[rhs-1]; - isize total = get_total_value_count(vd->values); - if (total > rhs) { - 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); - } + error(n, "Expected %td expressions on the right hand side, got %td", lhs, rhs); + error_line("Note: Global declarations do not allow for multi-valued expressions"); return false; } } diff --git a/src/parser.cpp b/src/parser.cpp index 3e6375321..868291177 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -2835,7 +2835,12 @@ Ast *parse_value_decl(AstFile *f, Array names, CommentGroup *docs) { if (f->curr_proc == nullptr) { 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 + ); } }