fix(tvix/eval): thread thunk forcing errors through correctly

With this, if an error occurs while forcing a thunk (which is very
likely) it is threaded through to the top by wrapping it in the
ErrorKind::ThunkForce variant.

We could use this to generate "stacktrace-like" error output if we
wanted, or simply jump through and discard everything except the
innermost error.

Change-Id: I3c1c8708c2f73ae062815adf490ce935b1979da8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6409
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-09-02 00:13:30 +03:00 committed by tazjin
parent 377ba19d75
commit 0a13d267f0
2 changed files with 7 additions and 3 deletions

View file

@ -48,6 +48,10 @@ pub enum ErrorKind {
// These are user-generated errors through builtins. // These are user-generated errors through builtins.
Throw(String), Throw(String),
Abort(String), Abort(String),
// An error occured while forcing a thunk, and needs to be chained
// up.
ThunkForce(Box<Error>),
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View file

@ -85,9 +85,9 @@ impl Thunk {
std::mem::replace(&mut *thunk_mut, ThunkRepr::Blackhole) std::mem::replace(&mut *thunk_mut, ThunkRepr::Blackhole)
{ {
vm.call(lambda, upvalues, 0); vm.call(lambda, upvalues, 0);
// TODO: find a cheap way to actually retain *thunk_mut = ThunkRepr::Evaluated(
// the original error span vm.run().map_err(|e| ErrorKind::ThunkForce(Box::new(e)))?,
*thunk_mut = ThunkRepr::Evaluated(vm.run().map_err(|e| e.kind)?); );
} }
} }
} }