diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-29 11:06:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-29 11:06:18 +0200 |
commit | ea1a4a3c8b7551a59667889edc35f806fd2ce45a (patch) | |
tree | 518acd348fefa25b99992c04ba04230fdf8f03a8 | |
parent | 05afdd8ca16c7066d12510a27e2fc08743bb2e95 (diff) |
Improve diagnostics for value subscript out of evaluation context
-rw-r--r-- | libbuild2/parser.cxx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index c8f66de..b4df45b 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -7759,8 +7759,27 @@ namespace build2 // This should be a simple value or a simple directory. // if (lv.size () > 1) - fail (loc) << "concatenating " << what << " contains multiple " - << "values"; + { + diag_record dr (fail (loc)); + + dr << "concatenating " << what << " contains multiple values"; + + // See if this looks like a subscript without an evaluation + // context and help the user out. + // + if (mode () != lexer_mode::eval) + { + const token& t (peeked ()); // Should be peeked at. + + if (t.type == type::word && + t.qtype == quote_type::unquoted && + t.value[0] == '[') + { + dr << info << "wrap it in (...) evaluation context if this " + << "is value subscript"; + } + } + } const name& n (lv[0]); |