about summary refs log tree commit diff
path: root/tvix/eval/src/eval.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-22T20·48+0300
committertazjin <tazjin@tvl.su>2022-09-01T21·40+0000
commitf7305eed47dea538611d0ae4c3545b646bce3727 (patch)
treea26d850fcfaa1eab4cccb47440539438707737f3 /tvix/eval/src/eval.rs
parent2662376941367d88687b3ebc4e4b941b266cee42 (diff)
refactor(tvix/eval): collect vector of errors in compiler r/4572
Instead of exiting the compiler at the first sight of an error,
skip any erroneous nodes and continue compiling, collecting more
errors along the way.

This paves the way for nicer error reporting in which multiple errors
can be reported at once, avoiding situations in which users are
hunting a fault error-by-error and possibly getting distracted by
less useful output.

Change-Id: I80c9a87272e33a31297167ae2eb2706a46adf15a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6236
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/eval.rs')
-rw-r--r--tvix/eval/src/eval.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs
index 8f2946e6cc..10d36904e4 100644
--- a/tvix/eval/src/eval.rs
+++ b/tvix/eval/src/eval.rs
@@ -41,5 +41,13 @@ pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
         )
     }
 
+    for error in &result.errors {
+        eprintln!("compiler error: {:?} at {:?}", error.kind, error.node,);
+    }
+
+    if let Some(err) = result.errors.last() {
+        return Err(err.clone());
+    }
+
     crate::vm::run_chunk(result.chunk)
 }