From 1cc5e2380158216ad65b4d9622c847479e495ebf Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 20 Mar 2024 18:14:29 +0000 Subject: [PATCH] Fix #3299 --- src/parser.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/parser.cpp b/src/parser.cpp index eb9e73342..54b0390bf 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -5440,14 +5440,27 @@ gb_internal AstPackage *try_add_import_path(Parser *p, String path, String const return nullptr; } + isize files_with_ext = 0; isize files_to_reserve = 1; // always reserve 1 for (FileInfo fi : list) { String name = fi.name; String ext = path_extension(name); + if (ext == FILE_EXT) { + files_with_ext += 1; + } if (ext == FILE_EXT && !is_excluded_target_filename(name)) { files_to_reserve += 1; } } + if (files_with_ext == 0 || files_to_reserve == 1) { + if (files_to_reserve == 1) { + syntax_error(pos, "Directory contains no .odin files for the specified platform: %.*s", LIT(rel_path)); + } else { + syntax_error(pos, "Empty directory that contains no .odin files: %.*s", LIT(rel_path)); + } + return nullptr; + } + array_reserve(&pkg->files, files_to_reserve); for (FileInfo fi : list) {