Make sure to assign proper comment as package docs

So far, the first comment found was marked as package docs, which
meant that for the following code, the TODO comment would be assigned
to the package declaration instead of the comment directly preceding
the package declaration.

    // TODO: drop after finished with refactoring
    #+ feature using-stmt
    // Package foo implements this and that.
    package foo
This commit is contained in:
Krzesimir Nowak
2026-02-24 16:31:16 +01:00
parent b8f2daa5b2
commit 1f00da471c

View File

@@ -6725,11 +6725,6 @@ gb_internal bool parse_file(Parser *p, AstFile *f) {
String filepath = f->tokenizer.fullpath;
String base_dir = dir_from_path(filepath);
if (f->curr_token.kind == Token_Comment) {
consume_comment_groups(f, f->prev_token);
}
CommentGroup *docs = f->lead_comment;
Array<Token> tags = array_make<Token>(temporary_allocator());
bool first_invalid_token_set = false;
@@ -6751,6 +6746,8 @@ gb_internal bool parse_file(Parser *p, AstFile *f) {
}
}
CommentGroup *docs = f->lead_comment;
if (f->curr_token.kind != Token_package) {
ERROR_BLOCK();