From 1f00da471cc223488cf333f5361445e120c51bbf Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Tue, 24 Feb 2026 16:31:16 +0100 Subject: [PATCH] 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 --- src/parser.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index 833e9ea9f..84fbc5130 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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 tags = array_make(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();