diff --git a/src/parser.cpp b/src/parser.cpp index 89a39e047..d981491dd 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6,13 +6,35 @@ gb_internal bool in_vet_packages(AstFile *file) { if (file == nullptr) { return true; } + if (file->pkg == nullptr) { return true; } + + if (file->pkg_decl == nullptr) { + return true; + } + if (build_context.vet_packages.entries.count == 0) { return true; } - return string_set_exists(&build_context.vet_packages, file->pkg->name); + + String pkg_name = {}; + + if (file->pkg->name.len > 0) { + pkg_name = file->pkg->name; + } else if (file->pkg_decl->kind == Ast_PackageDecl) { + Token name_token = file->pkg_decl->PackageDecl.name; + if (name_token.kind == Token_Ident) { + pkg_name = name_token.string; + } + } + + if (pkg_name.len == 0) { + return true; + } + + return string_set_exists(&build_context.vet_packages, pkg_name); } gb_internal u64 ast_file_vet_flags(AstFile *f) {