diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-30 18:04:08 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-07-30 18:49:19 +0200 |
| commit | 1ee1d078e2480ddd08d40915bc7a74a8352acff0 (patch) | |
| tree | 1e7ff367278a19fead3e404cf06d65bfb80a6cd9 /src/eval/scope.rs | |
| parent | 42a27b48df427edf8dbb624c51551a90ecf2e7ea (diff) | |
Fatal errors
- Makes errors fatal, so that a phase is only reached when all previous phases were error-free
- Parsing still recovers and can produce multiple errors
- Evaluation fails fast and can thus produce only a single error (except for parse errors due to an import)
- The single error that could occur during execution is removed for now
- Removes Value::Error variant
Diffstat (limited to 'src/eval/scope.rs')
| -rw-r--r-- | src/eval/scope.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/eval/scope.rs b/src/eval/scope.rs index 72b524cf..2eb048fa 100644 --- a/src/eval/scope.rs +++ b/src/eval/scope.rs @@ -4,7 +4,9 @@ use std::fmt::{self, Debug, Formatter}; use std::iter; use std::rc::Rc; -use super::{EcoString, EvalContext, FuncArgs, Function, Value}; +use super::{EvalContext, FuncArgs, Function, Value}; +use crate::diag::TypResult; +use crate::util::EcoString; /// A slot where a variable is stored. pub type Slot = Rc<RefCell<Value>>; @@ -89,7 +91,7 @@ impl Scope { /// Define a constant function. pub fn def_func<F>(&mut self, name: impl Into<EcoString>, f: F) where - F: Fn(&mut EvalContext, &mut FuncArgs) -> Value + 'static, + F: Fn(&mut EvalContext, &mut FuncArgs) -> TypResult<Value> + 'static, { let name = name.into(); self.def_const(name.clone(), Function::new(Some(name), f)); |
