Skip to content

Commit

Permalink
resolveLookupPathPath(): Fix caching of negative lookups
Browse files Browse the repository at this point in the history
This avoids spamming in case the missing search path entry does not
exist (NixOS#12480).
  • Loading branch information
edolstra committed Feb 17, 2025
1 parent 8ac49ea commit df08e1e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3070,8 +3070,11 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat
auto i = lookupPathResolved.find(value);
if (i != lookupPathResolved.end()) return i->second;

auto finish = [&](SourcePath res) {
debug("resolved search path element '%s' to '%s'", value, res);
auto finish = [&](std::optional<SourcePath> 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;
};
Expand Down Expand Up @@ -3123,8 +3126,7 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat
}
}

debug("failed to resolve search path element '%s'", value);
return std::nullopt;
return finish(std::nullopt);
}


Expand Down

0 comments on commit df08e1e

Please sign in to comment.