fix(tvix/eval): Actually trace spans for thunks

Currently, the span on *all* thunk force errors is the span at which the
thunk is forced, which for recursive thunk forcing ends up just being
the same span over and over again. This changes the span on thunk force
errors to be the span at which point the thunk is *created*, which is a
bit more helpful (though the printing atm is a little... crowded). To
make this work, we have to thread through the span at which a thunk is
created into a field on the thunk itself.

Change-Id: I81474810a763046e2eb3a8f07acf7d8ec708824a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6932
Autosubmit: grfn <grfn@gws.fyi>
Reviewed-by: Adam Joseph <adam@westernsemico.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2022-10-10 16:50:28 -04:00 committed by grfn
parent 90ec632fd1
commit 06ec4bebe7
4 changed files with 34 additions and 22 deletions

View file

@ -186,7 +186,7 @@ impl<'o> VM<'o> {
/// Returns the source span of the instruction currently being
/// executed.
fn current_span(&self) -> codemap::Span {
pub(crate) fn current_span(&self) -> codemap::Span {
self.chunk().get_span(self.frame().ip - 1)
}
@ -637,7 +637,7 @@ impl<'o> VM<'o> {
};
let upvalue_count = blueprint.upvalue_count;
let thunk = Thunk::new(blueprint);
let thunk = Thunk::new(blueprint, self.current_span());
let upvalues = thunk.upvalues_mut();
self.push(Value::Thunk(thunk.clone()));