From 7aabdc2ccfea23c93e3b94290df59708aa179104 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 20 Jul 2023 07:30:19 +0200 Subject: Improve diagnostics --- libbuild2/functions-name.cxx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libbuild2/functions-name.cxx b/libbuild2/functions-name.cxx index 84608d4..a853db1 100644 --- a/libbuild2/functions-name.cxx +++ b/libbuild2/functions-name.cxx @@ -48,9 +48,22 @@ namespace build2 if (const target* r = search_existing (n, s, o.dir)) return *r; - fail << "target " - << (n.pair ? names {move (n), move (o)} : names {move (n)}) - << " not found" << endf; + // Inside recipes we don't treat `{}` as special so a literal target name + // will have no type and won't be found, which is confusing as hell. + // + bool typed (n.typed ()); + + diag_record dr (fail); + + dr << "target " + << (n.pair ? names {move (n), move (o)} : names {move (n)}) + << " not found"; + + if (!typed) + dr << info << "wrap it in ([names] ...) if this is literal target name " + << "specified inside recipe"; + + dr << endf; } const target& -- cgit v1.1