aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-01-31 13:39:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-01-31 13:39:45 +0200
commit53e34adc6fa856fcc55c0917dbfc9bbc855cb5ad (patch)
tree0f0c39d6c3b344a45bbb55e9ee08add6d53702d2
parent84d8b7196f27f0ac195207e31865502e7160840f (diff)
Minor improvement to diagnostics
-rw-r--r--libbuild2/parser.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 0d51b49..0b8fb42 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -4783,9 +4783,13 @@ namespace build2
{
// Parse and enter a variable name for assignment (as opposed to lookup).
- // The list should contain a single, simple name.
+ // The list should contain a single, simple name. Go an extra mile to
+ // issue less confusing diagnostics.
//
- if (ns.size () != 1 || ns[0].pattern || !ns[0].simple () || ns[0].empty ())
+ size_t n (ns.size ());
+ if (n == 0 || (n == 1 && ns[0].empty ()))
+ fail (l) << "empty variable name";
+ else if (n != 1 || ns[0].pattern || !ns[0].simple ())
fail (l) << "expected variable name instead of " << ns;
return parse_variable_name (move (ns[0].value), l);