summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-03-14 17:21:13 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-03-14 17:21:13 +0100
commitc56bc3d81cdcc09daf331b253a42cd155a9bd5f2 (patch)
tree4288b4ccae49f9b35cb5d9cf6d0636ebb6c79865
parent4b07476848f7738c07a5b0894ad7a848ee2e9c9d (diff)
downloadguix-c56bc3d81cdcc09daf331b253a42cd155a9bd5f2.tar.gz
Make sure that thunks are restored properly if an exception occurs
Fixes Hydra bug #67.
-rw-r--r--src/libexpr/eval-inline.hh9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh
index 57a9e4c63c..722273ddad 100644
--- a/src/libexpr/eval-inline.hh
+++ b/src/libexpr/eval-inline.hh
@@ -21,13 +21,16 @@ LocalNoInlineNoReturn(void throwTypeError(const char * s, const string & s2))
 void EvalState::forceValue(Value & v)
 {
     if (v.type == tThunk) {
-        ValueType saved = v.type;
+        Env * env = v.thunk.env;
+        Expr * expr = v.thunk.expr;
         try {
             v.type = tBlackhole;
             //checkInterrupt();
-            v.thunk.expr->eval(*this, *v.thunk.env, v);
+            expr->eval(*this, *env, v);
         } catch (Error & e) {
-            v.type = saved;
+            v.type = tThunk;
+            v.thunk.env = env;
+            v.thunk.expr = expr;
             throw;
         }
     }