feat(tvix/eval): track span of first force in a thunk blackhole
This is step 1 towards being able to use all 4 spans that we know when dealing with infinite recursion. It tracks the span at which the force of a thunk was first requested when constructing a blackhole, so that we can highlight the spans of the first and second forces. These are actually the least relevant spans, but the easiest to put in place, more coming soon. Change-Id: I4c7e82f6211b98756439d4148a4191457cc46807 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8269 Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
5095e4f269
commit
3fa6b13c1e
5 changed files with 48 additions and 17 deletions
|
|
@ -77,7 +77,9 @@ pub enum ErrorKind {
|
|||
NotCallable(&'static str),
|
||||
|
||||
/// Infinite recursion encountered while forcing thunks.
|
||||
InfiniteRecursion,
|
||||
InfiniteRecursion {
|
||||
first_force: Span,
|
||||
},
|
||||
|
||||
ParseErrors(Vec<rnix::parser::ParseError>),
|
||||
|
||||
|
|
@ -354,7 +356,7 @@ to a missing value in the attribute set(s) included via `with`."#,
|
|||
)
|
||||
}
|
||||
|
||||
ErrorKind::InfiniteRecursion => write!(f, "infinite recursion encountered"),
|
||||
ErrorKind::InfiniteRecursion { .. } => write!(f, "infinite recursion encountered"),
|
||||
|
||||
// Errors themselves ignored here & handled in Self::spans instead
|
||||
ErrorKind::ParseErrors(_) => write!(f, "failed to parse Nix code:"),
|
||||
|
|
@ -754,7 +756,7 @@ impl Error {
|
|||
| ErrorKind::UnknownDynamicVariable(_)
|
||||
| ErrorKind::VariableAlreadyDefined(_)
|
||||
| ErrorKind::NotCallable(_)
|
||||
| ErrorKind::InfiniteRecursion
|
||||
| ErrorKind::InfiniteRecursion { .. }
|
||||
| ErrorKind::ParseErrors(_)
|
||||
| ErrorKind::NativeError { .. }
|
||||
| ErrorKind::BytecodeError(_)
|
||||
|
|
@ -797,7 +799,7 @@ impl Error {
|
|||
ErrorKind::UnknownDynamicVariable(_) => "E011",
|
||||
ErrorKind::VariableAlreadyDefined(_) => "E012",
|
||||
ErrorKind::NotCallable(_) => "E013",
|
||||
ErrorKind::InfiniteRecursion => "E014",
|
||||
ErrorKind::InfiniteRecursion { .. } => "E014",
|
||||
ErrorKind::ParseErrors(_) => "E015",
|
||||
ErrorKind::DuplicateAttrsKey { .. } => "E016",
|
||||
ErrorKind::NotCoercibleToString { .. } => "E018",
|
||||
|
|
@ -869,6 +871,21 @@ impl Error {
|
|||
]
|
||||
}
|
||||
|
||||
ErrorKind::InfiniteRecursion { first_force } => {
|
||||
vec![
|
||||
SpanLabel {
|
||||
label: Some("first requested here".into()),
|
||||
span: *first_force,
|
||||
style: SpanStyle::Secondary,
|
||||
},
|
||||
SpanLabel {
|
||||
label: Some("requested again here".into()),
|
||||
span: self.span,
|
||||
style: SpanStyle::Primary,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// All other errors pretty much have the same shape.
|
||||
_ => {
|
||||
vec![SpanLabel {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue