Skip to content

Commit

Permalink
Manifest: define keywords as global (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui authored Jan 31, 2025
1 parent 69cd916 commit 9265493
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ static const fs::path GIT_SRC_DIR(GIT_DIR / "src");
static const std::unordered_set<char> ALLOWED_CHARS = {
'-', '_', '/', '.', '+' // allowed in the dependency name
};
static const std::unordered_set<std::string_view> KEYWORDS = {
#include "Keywords.def"
};

Result<Edition>
Edition::tryFromString(std::string str) noexcept {
Expand Down Expand Up @@ -550,11 +553,7 @@ validatePackageName(const std::string_view name) noexcept {
std::isalnum(name[name.size() - 1]),
"package name must end with a letter or digit"
);

const std::unordered_set<std::string_view> keywords = {
#include "Keywords.def"
};
Ensure(!keywords.contains(name), "package name must not be a C++ keyword");
Ensure(!KEYWORDS.contains(name), "package name must not be a C++ keyword");

return Ok();
}
Expand Down

0 comments on commit 9265493

Please sign in to comment.