diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc index 210f43f4d..8705a5851 100644 --- a/src/libexpr/eval-cache.cc +++ b/src/libexpr/eval-cache.cc @@ -6,9 +6,9 @@ namespace nix::eval_cache { -CachedEvalError::CachedEvalError(ref cursor, Symbol attr) +CachedEvalError::CachedEvalError(ref state, ref cursor, Symbol attr) : EvalError("cached failure of attribute '%s'", cursor->getAttrPathStr(attr)) - , cursor(cursor), attr(attr) + , state(state), cursor(cursor), attr(attr) { } void CachedEvalError::force() @@ -18,7 +18,7 @@ void CachedEvalError::force() if (v.type() == nAttrs) { auto a = v.attrs->get(this->attr); - state.forceValue(*a->value, a->pos); + state->forceValue(*a->value, a->pos); } // Shouldn't happen. @@ -506,7 +506,7 @@ std::shared_ptr AttrCursor::maybeGetAttr(Symbol name) if (std::get_if(&attr->second)) return nullptr; else if (std::get_if(&attr->second)) - throw CachedEvalError(ref(shared_from_this()), name); + throw CachedEvalError(ref(root->state.shared_from_this()), ref(shared_from_this()), name); else return std::make_shared(root, std::make_pair(shared_from_this(), name), nullptr, std::move(attr)); diff --git a/src/libexpr/eval-cache.hh b/src/libexpr/eval-cache.hh index cac985829..d025872fa 100644 --- a/src/libexpr/eval-cache.hh +++ b/src/libexpr/eval-cache.hh @@ -15,10 +15,11 @@ class AttrCursor; struct CachedEvalError : EvalError { + const ref state; const ref cursor; const Symbol attr; - CachedEvalError(ref cursor, Symbol attr); + CachedEvalError(ref, ref cursor, Symbol attr); /** * Evaluate this attribute, which should result in a regular