From 4afc8ffdfe7ca2976bbab9d59da4c2ae11902c2f Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 30 Mar 2021 19:33:46 +0530 Subject: add assert primitive; pass state in Evaluator --- src/lisp/error.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/lisp/error.rs') diff --git a/src/lisp/error.rs b/src/lisp/error.rs index 53681d8..f905e6d 100644 --- a/src/lisp/error.rs +++ b/src/lisp/error.rs @@ -1,5 +1,5 @@ use crate::lisp::{ - expr::Arity, + expr::{Arity, LispExpr}, lex::{Span, SpanDisplay}, }; @@ -98,6 +98,7 @@ pub enum EvalError { TypeMismatch, NoFileName, AccessEmptyList, + AssertionError { expected: LispExpr, got: LispExpr }, ScriptLoadError(io::Error), CustomInternal(&'static str), Custom(String), @@ -124,6 +125,9 @@ impl fmt::Display for EvalError { Self::DivByZero => write!(f, "attempt to divide by zero"), Self::NoFileName => write!(f, "no file name specified"), Self::AccessEmptyList => write!(f, "attempted to access empty list"), + Self::AssertionError { expected, got } => { + write!(f, "assertion error: expected `{}` got `{}`", expected, got) + } Self::ScriptLoadError(s) => write!(f, "error while loading script: {}", s), Self::CustomInternal(s) => write!(f, "{}", s), Self::Custom(s) => write!(f, "error: {}", s), -- cgit v1.2.3