Skip to content

Commit

Permalink
Store ref<EvalState> in CachedEvalError
Browse files Browse the repository at this point in the history
This makes the previous commits work.
Newer versions store it in all EvalErrors.
  • Loading branch information
roberth committed Sep 8, 2024
1 parent ef63ba1 commit 5bcc706
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/libexpr/eval-cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

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))
, cursor(cursor), attr(attr)
, state(state), cursor(cursor), attr(attr)
{ }

void CachedEvalError::force()
Expand All @@ -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.
Expand Down Expand Up @@ -506,7 +506,7 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name)
if (std::get_if<missing_t>(&attr->second))
return nullptr;
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
return std::make_shared<AttrCursor>(root,
std::make_pair(shared_from_this(), name), nullptr, std::move(attr));
Expand Down
3 changes: 2 additions & 1 deletion src/libexpr/eval-cache.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class AttrCursor;

struct CachedEvalError : EvalError
{
const ref<EvalState> state;
const ref<AttrCursor> cursor;
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
Expand Down

0 comments on commit 5bcc706

Please sign in to comment.