about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-04-08T11·25+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-08T11·25+0000
commit7e048eddf55637b9e81d704f6b9f1fdeca98a5ea (patch)
treec2f39dec45c5e2c6b84f7cde29fbd03438038481 /src/libexpr/eval.cc
parentaf2a372bb000d4d5aeec37e43ee0f6245c1bba54 (diff)
* Fix blackholing. If evaluation fails due to an assertion failure,
  then the blackhole has to be removed to ensure that repeated
  evaluation of the same value gives an assertion failure again rather
  than an "infinite recursion" error.

Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 98b6b7bdd1..e72538e608 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -681,8 +681,14 @@ bool EvalState::evalBool(Env & env, Expr e)
 void EvalState::forceValue(Value & v)
 {
     if (v.type == tThunk) {
-        //v.type = tBlackhole;
-        eval(*v.thunk.env, v.thunk.expr, v);
+        ValueType saved = v.type;
+        try {
+            v.type = tBlackhole;
+            eval(*v.thunk.env, v.thunk.expr, v);
+        } catch (Error & e) {
+            v.type = saved;
+            throw;
+        }
     }
     else if (v.type == tCopy) {
         forceValue(*v.val);