aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-11-19 20:59:36 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-11-19 20:59:36 +0100
commit4dcb183af31d5cb33b6ef8e581e77d1c892a58b9 (patch)
tree91b559c04da17e8ed10aa2c89b9486e5922fa54f /src
parent0327580e5485143acb6eb7c8c515e3e179f1e3fe (diff)
AttrCursor::getStringWithContext(): Force re-evaluation if the cached context is not valid
Fixes #4236.
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval-cache.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc
index 381344b40..7b025be23 100644
--- a/src/libexpr/eval-cache.cc
+++ b/src/libexpr/eval-cache.cc
@@ -525,8 +525,17 @@ string_t AttrCursor::getStringWithContext()
cachedValue = root->db->getAttr(getKey(), root->state.symbols);
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
if (auto s = std::get_if<string_t>(&cachedValue->second)) {
- debug("using cached string attribute '%s'", getAttrPathStr());
- return *s;
+ bool valid = true;
+ for (auto & c : s->second) {
+ if (!root->state.store->isValidPath(root->state.store->parseStorePath(c.first))) {
+ valid = false;
+ break;
+ }
+ }
+ if (valid) {
+ debug("using cached string attribute '%s'", getAttrPathStr());
+ return *s;
+ }
} else
throw TypeError("'%s' is not a string", getAttrPathStr());
}