From 995cd7946bf605804603fe79c6cef1ddf6db83b5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 21 Feb 2022 06:51:45 +0200 Subject: Ban module names that start with underscore --- libbuild2/buildfile | 9 ++++++--- libbuild2/parser.cxx | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libbuild2/buildfile b/libbuild2/buildfile index b6c59a5..2fb4bde 100644 --- a/libbuild2/buildfile +++ b/libbuild2/buildfile @@ -227,9 +227,12 @@ else # Generated options parser. # -# @@ Consider generating common cli runtime namespace if adding more option -# files. Plus sommon types-parser.?xx (which could also potentially be -# reused by the driver). +# Note that the cli runtime namespace is build2::build::cli rather than +# build2::cli. That's because the cli namespace inside build2 is reserved for +# the cli build system module (libbuild2-cli). In fact, every namespace inside +# build2 is reserved for a potential module and the only namespace names we +# can use are build (this name, along with import and export, is reserved by +# the build system core) and names that start with an underscore. # if $cli.configured { diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index bec3230..b76bb18 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -3348,6 +3348,9 @@ namespace build2 n = move (i->value); + if (n[0] == '_') + fail (l) << "module name '" << n << "' starts with underscore"; + if (i->pair) try { -- cgit v1.1