From 5bcc7069bec00ee86669f98961dbe2a319d6f6d9 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 9 Sep 2024 00:38:28 +0200 Subject: [PATCH] Store ref in CachedEvalError This makes the previous commits work. Newer versions store it in all EvalErrors. --- src/libexpr/eval-cache.cc | 8 ++++---- src/libexpr/eval-cache.hh | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) 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