diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-01-31 13:39:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-01-31 13:39:45 +0200 |
commit | 53e34adc6fa856fcc55c0917dbfc9bbc855cb5ad (patch) | |
tree | 0f0c39d6c3b344a45bbb55e9ee08add6d53702d2 /libbuild2/parser.cxx | |
parent | 84d8b7196f27f0ac195207e31865502e7160840f (diff) |
Minor improvement to diagnostics
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r-- | libbuild2/parser.cxx | 8 |
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); |