From 0257f89917e479b77b231724c13192ec23258269 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 15 Aug 2022 01:47:30 +0300 Subject: 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 Reviewed-by: grfn --- tvix/eval/src/errors.rs | 2 ++ tvix/eval/src/eval.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index a5ba5bf400..07ee8a4c7d 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), } impl Display for Error { diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs index d8037ea143..94290af537 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) -> EvalResult { 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() { -- cgit 1.4.1