feat(tvix/eval): carry optional SyntaxNode in error type

This starts paving the way for nicer, source-code based error
reporting.

Right now the code paths in the VM do not emit annotated errors, as we
do not yet preserve that structure from the compiler. However, error
emitting code paths in the compiler have been amended to include known
nodes.

Change-Id: I1b74410ffd891c40cd913361bd73c4336ec8aa5b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6235
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-08-22 23:20:50 +03:00 committed by tazjin
parent 51be6542c9
commit 2662376941
6 changed files with 62 additions and 40 deletions

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
use rnix;
use crate::{
errors::{Error, EvalResult},
errors::{ErrorKind, EvalResult},
value::Value,
};
@ -15,7 +15,7 @@ pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
for err in errors {
eprintln!("parse error: {}", err);
}
return Err(Error::ParseErrors(errors.to_vec()));
return Err(ErrorKind::ParseErrors(errors.to_vec()).into());
}
// If we've reached this point, there are no errors.