diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index 59142f2ef..5f1a24b54 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -48,6 +48,10 @@ pub enum ErrorKind { // These are user-generated errors through builtins. Throw(String), Abort(String), + + // An error occured while forcing a thunk, and needs to be chained + // up. + ThunkForce(Box), } #[derive(Clone, Debug)] diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs index c2552284f..4fd41689c 100644 --- a/tvix/eval/src/value/thunk.rs +++ b/tvix/eval/src/value/thunk.rs @@ -85,9 +85,9 @@ impl Thunk { std::mem::replace(&mut *thunk_mut, ThunkRepr::Blackhole) { vm.call(lambda, upvalues, 0); - // TODO: find a cheap way to actually retain - // the original error span - *thunk_mut = ThunkRepr::Evaluated(vm.run().map_err(|e| e.kind)?); + *thunk_mut = ThunkRepr::Evaluated( + vm.run().map_err(|e| ErrorKind::ThunkForce(Box::new(e)))?, + ); } } }