refactor(tvix/eval): collect vector of errors in compiler

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>
This commit is contained in:
Vincent Ambo 2022-08-22 23:48:47 +03:00 committed by tazjin
parent 2662376941
commit f7305eed47
3 changed files with 111 additions and 102 deletions

View file

@ -1,6 +1,6 @@
use std::fmt::Display;
#[derive(Debug)]
#[derive(Clone, Debug)]
pub enum ErrorKind {
DuplicateAttrsKey {
key: String,
@ -27,7 +27,7 @@ pub enum ErrorKind {
DynamicKeyInLet(rnix::SyntaxNode),
// Unknown variable in statically known scope.
UnknownStaticVariable(rnix::ast::Ident),
UnknownStaticVariable,
// Unknown variable in dynamic scope (with, rec, ...).
UnknownDynamicVariable(String),
@ -37,7 +37,7 @@ pub enum ErrorKind {
AssertionFailed,
}
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct Error {
pub node: Option<rnix::SyntaxNode>,
pub kind: ErrorKind,