about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-14T22·47+0300
committertazjin <tazjin@tvl.su>2022-08-31T22·42+0000
commit0257f89917e479b77b231724c13192ec23258269 (patch)
tree7dc6cb2e77066cc26478ffaaed79831432aac14c /tvix
parent89f566ef5782c967e14eee5727dce2740a3c24b4 (diff)
chore(tvix/eval): return parse errors out of eval::interpret r/4558
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>
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/errors.rs2
-rw-r--r--tvix/eval/src/eval.rs10
2 files changed, 10 insertions, 2 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index a5ba5bf40059..07ee8a4c7dae 100644
--- a/tvix/eval/src/errors.rs
+++ b/tvix/eval/src/errors.rs
@@ -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 {
diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs
index d8037ea143c7..94290af5376d 100644
--- a/tvix/eval/src/eval.rs
+++ b/tvix/eval/src/eval.rs
@@ -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() {