chore(tvix/eval): return parse errors out of eval::interpret
Change-Id: I14f25b9c85260c68be38abf07ed80121ead60c7b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6224 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
89f566ef57
commit
0257f89917
2 changed files with 10 additions and 2 deletions
|
@ -31,6 +31,8 @@ pub enum Error {
|
|||
|
||||
// Unknown variable in dynamic scope (with, rec, ...).
|
||||
UnknownDynamicVariable(String),
|
||||
|
||||
ParseErrors(Vec<rnix::parser::ParseError>),
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
|
|
|
@ -2,14 +2,20 @@ use std::path::PathBuf;
|
|||
|
||||
use rnix::{self, types::TypedNode};
|
||||
|
||||
use crate::{errors::EvalResult, value::Value};
|
||||
use crate::{
|
||||
errors::{Error, EvalResult},
|
||||
value::Value,
|
||||
};
|
||||
|
||||
pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
|
||||
let ast = rnix::parse(code);
|
||||
|
||||
let errors = ast.errors();
|
||||
if !errors.is_empty() {
|
||||
todo!()
|
||||
for err in &errors {
|
||||
eprintln!("parse error: {}", err);
|
||||
return Err(Error::ParseErrors(errors));
|
||||
}
|
||||
}
|
||||
|
||||
if std::env::var("TVIX_DISPLAY_AST").is_ok() {
|
||||
|
|
Loading…
Reference in a new issue