From 53e34adc6fa856fcc55c0917dbfc9bbc855cb5ad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 31 Jan 2023 13:39:45 +0200 Subject: Minor improvement to diagnostics --- libbuild2/parser.cxx | 8 ++++++-- 1 file 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); -- cgit v1.1