about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/eval.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/libexpr/eval.cc')
-rw-r--r--third_party/nix/src/libexpr/eval.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 3d134be19e..e04bf7fc49 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -600,10 +600,13 @@ inline Value* EvalState::lookupVar(Env* env, const ExprVar& var, bool noEval) {
       if (noEval) {
         return nullptr;
       }
+      if (!env->withAttrsExpr) {
+        CHECK(false) << "HasWithExpr evaluated twice";
+      }
       Value* v = allocValue();
-      // TODO(kanepyork): Here's the other end of the cast smuggle.
-      evalAttrs(*env->up, reinterpret_cast<Expr*>(env->values[0]), *v);
+      evalAttrs(*env->up, env->withAttrsExpr, *v);
       env->values[0] = v;
+      env->withAttrsExpr = nullptr;
       env->type = Env::HasWithAttrs;
     }
     Bindings::iterator j = env->values[0]->attrs->find(var.name);
@@ -1179,9 +1182,9 @@ void ExprWith::eval(EvalState& state, Env& env, Value& v) {
   env2.up = &env;
   env2.prevWith = prevWith;
   env2.type = Env::HasWithExpr;
-  // TODO(kanepyork): Figure out what's going on here. `Expr* attrs` is not
-  // layout-compatible with Value*.
-  env2.values[0] = reinterpret_cast<Value*>(attrs);
+  /* placeholder for result of attrs */
+  env2.values[0] = nullptr;
+  env2.withAttrsExpr = this->attrs;
 
   body->eval(state, env2, v);
 }