Store ref<EvalState> in CachedEvalError

This makes the previous commits work.
Newer versions store it in all EvalErrors.
This commit is contained in:
Robert Hensing 2024-09-09 00:38:28 +02:00
parent ef63ba10a2
commit 5bcc7069be
2 changed files with 6 additions and 5 deletions

View File

@ -6,9 +6,9 @@
namespace nix::eval_cache { namespace nix::eval_cache {
CachedEvalError::CachedEvalError(ref<AttrCursor> cursor, Symbol attr) CachedEvalError::CachedEvalError(ref<EvalState> state, ref<AttrCursor> cursor, Symbol attr)
: EvalError("cached failure of attribute '%s'", cursor->getAttrPathStr(attr)) : EvalError("cached failure of attribute '%s'", cursor->getAttrPathStr(attr))
, cursor(cursor), attr(attr) , state(state), cursor(cursor), attr(attr)
{ } { }
void CachedEvalError::force() void CachedEvalError::force()
@ -18,7 +18,7 @@ void CachedEvalError::force()
if (v.type() == nAttrs) { if (v.type() == nAttrs) {
auto a = v.attrs->get(this->attr); auto a = v.attrs->get(this->attr);
state.forceValue(*a->value, a->pos); state->forceValue(*a->value, a->pos);
} }
// Shouldn't happen. // Shouldn't happen.
@ -506,7 +506,7 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name)
if (std::get_if<missing_t>(&attr->second)) if (std::get_if<missing_t>(&attr->second))
return nullptr; return nullptr;
else if (std::get_if<failed_t>(&attr->second)) else if (std::get_if<failed_t>(&attr->second))
throw CachedEvalError(ref(shared_from_this()), name); throw CachedEvalError(ref(root->state.shared_from_this()), ref(shared_from_this()), name);
else else
return std::make_shared<AttrCursor>(root, return std::make_shared<AttrCursor>(root,
std::make_pair(shared_from_this(), name), nullptr, std::move(attr)); std::make_pair(shared_from_this(), name), nullptr, std::move(attr));

View File

@ -15,10 +15,11 @@ class AttrCursor;
struct CachedEvalError : EvalError struct CachedEvalError : EvalError
{ {
const ref<EvalState> state;
const ref<AttrCursor> cursor; const ref<AttrCursor> cursor;
const Symbol attr; const Symbol attr;
CachedEvalError(ref<AttrCursor> cursor, Symbol attr); CachedEvalError(ref<EvalState>, ref<AttrCursor> cursor, Symbol attr);
/** /**
* Evaluate this attribute, which should result in a regular * Evaluate this attribute, which should result in a regular