summaryrefslogtreecommitdiff
path: root/src/eval/func.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval/func.rs')
-rw-r--r--src/eval/func.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/eval/func.rs b/src/eval/func.rs
index cd54a140..b870fd9d 100644
--- a/src/eval/func.rs
+++ b/src/eval/func.rs
@@ -2,7 +2,7 @@ use std::fmt::{self, Debug, Formatter, Write};
use std::hash::{Hash, Hasher};
use std::sync::Arc;
-use super::{Cast, Eval, Scope, Scopes, Value};
+use super::{Cast, Control, Eval, Scope, Scopes, Value};
use crate::diag::{At, TypResult};
use crate::syntax::ast::Expr;
use crate::syntax::{Span, Spanned};
@@ -138,7 +138,11 @@ impl Closure {
}
// Evaluate the body.
- let value = self.body.eval(ctx, &mut scp)?;
+ let value = match self.body.eval(ctx, &mut scp) {
+ Ok(value) => value,
+ Err(Control::Return(value, _)) => return Ok(value.unwrap_or_default()),
+ other => other?,
+ };
Ok(value)
}