aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-03-24 14:34:30 +0000
committergingerBill <bill@gingerbill.org>2021-03-24 14:34:30 +0000
commita5329ae48c1a9a8cc1575e40a0ce396e5cc5c93b (patch)
treee90e15f376d764047d088ce3e827662780129b7a /src/parser.cpp
parent2ec3326653cfea2ce846305966f8eb5e03c62595 (diff)
Add better package declaration specific error message (#878)
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 8f1741054..f7e98d071 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -5204,6 +5204,11 @@ bool parse_file(Parser *p, AstFile *f) {
CommentGroup *docs = f->lead_comment;
+ if (f->curr_token.kind != Token_package) {
+ syntax_error(f->curr_token, "Expected a package declaration at the beginning of the file");
+ return false;
+ }
+
f->package_token = expect_token(f, Token_package);
if (f->package_token.kind != Token_package) {
return false;