aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorAndreas T Jonsson <mail@andreasjonsson.se>2024-04-25 22:04:40 +0200
committerAndreas T Jonsson <mail@andreasjonsson.se>2024-04-25 22:04:40 +0200
commit9a008d10f3d8f97ff11ba948d6939bec7e6beb6d (patch)
tree8b2fd91da22620b6e0a7158a66429f1af4aca210 /src/parser.cpp
parent3000508c027c9d30c168266d0ae276cc14de3982 (diff)
parentf745fff640ab1582bdfdd18a7239c58fa37db753 (diff)
Merge branch 'master' into netbsd
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 01a3069ff..f4d3dc48d 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -6114,7 +6114,13 @@ gb_internal bool parse_file(Parser *p, AstFile *f) {
CommentGroup *docs = f->lead_comment;
if (f->curr_token.kind != Token_package) {
+ ERROR_BLOCK();
syntax_error(f->curr_token, "Expected a package declaration at the beginning of the file");
+ // IMPORTANT NOTE(bill): this is technically a race condition with the suggestion, but it's ony a suggession
+ // so in practice is should be "fine"
+ if (f->pkg && f->pkg->name != "") {
+ error_line("\tSuggestion: Add 'package %.*s' to the top of the file\n", LIT(f->pkg->name));
+ }
return false;
}