From b7066421339017d19101c7dc6cb11a8811a7909e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 17 Feb 2025 11:50:54 +0100 Subject: [PATCH] resolveLookupPathPath(): Fix caching of negative lookups This avoids spamming in case the missing search path entry does not exist (#12480). (cherry picked from commit df08e1e204d04924bc546ed3ebb2fabf936aa5be) --- src/libexpr/eval.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index ee72436e4..463f361d3 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -3084,8 +3084,11 @@ std::optional EvalState::resolveLookupPathPath(const LookupPath::Pa auto i = lookupPathResolved.find(value); if (i != lookupPathResolved.end()) return i->second; - auto finish = [&](std::string res) { - debug("resolved search path element '%s' to '%s'", value, res); + auto finish = [&](std::optional res) { + if (res) + debug("resolved search path element '%s' to '%s'", value, *res); + else + debug("failed to resolve search path element '%s'", value); lookupPathResolved.emplace(value, res); return res; }; @@ -3137,9 +3140,7 @@ std::optional EvalState::resolveLookupPathPath(const LookupPath::Pa } } - debug("failed to resolve search path element '%s'", value); - return std::nullopt; - + return finish(std::nullopt); }