feat(tvix/eval): chain error spans for thunk errors
Adds secondary spans for errors that occur deeply nested within a thunk. This is pretty raw right now, there's technically nothing stopping one of these error chains from being a hundred thunks deep into code, producing unmanageable error output. We should trim these down according to some heuristics (e.g. when crossing file boundaries, o r just - for starters - beginning and end). Change-Id: Ia73892512737850b6fa3e07cabc37fa9c534c4d5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6872 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
1e2d323a7c
commit
9b1a266197
1 changed files with 21 additions and 0 deletions
|
@ -601,6 +601,27 @@ to a missing value in the attribute set(s) included via `with`."#,
|
|||
spans_for_parse_errors(&file, errors)
|
||||
}
|
||||
|
||||
// Unwrap thunk errors to the innermost one
|
||||
// TODO: limit the number of intermediates!
|
||||
ErrorKind::ThunkForce(err) => {
|
||||
let mut labels = err.spans(source);
|
||||
|
||||
// Only add this thunk to the "cause chain" if it span isn't
|
||||
// exactly identical to the next-higher level, which is very
|
||||
// common for the last thunk in a chain.
|
||||
if let Some(label) = labels.last() {
|
||||
if label.span != self.span {
|
||||
labels.push(SpanLabel {
|
||||
label: Some("while evaluating this".into()),
|
||||
span: self.span,
|
||||
style: SpanStyle::Secondary,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
labels
|
||||
}
|
||||
|
||||
// All other errors pretty much have the same shape.
|
||||
_ => {
|
||||
vec![SpanLabel {
|
||||
|
|
Loading…
Reference in a new issue