about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/rlox/src/errors.rs')
-rw-r--r--users/tazjin/rlox/src/errors.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/errors.rs b/users/tazjin/rlox/src/errors.rs
index 4f173d016039..875f268ca64d 100644
--- a/users/tazjin/rlox/src/errors.rs
+++ b/users/tazjin/rlox/src/errors.rs
@@ -1,3 +1,5 @@
+use crate::interpreter::Value;
+
 #[derive(Debug)]
 pub enum ErrorKind {
     UnexpectedChar(char),
@@ -12,6 +14,16 @@ pub enum ErrorKind {
     InternalError(String),
     InvalidAssignmentTarget(String),
     RuntimeError(String),
+
+    // This variant is not an error, rather it is used for
+    // short-circuiting out of a function body that hits a `return`
+    // statement.
+    //
+    // It's implemented this way because in the original book the
+    // author uses exceptions for control flow, and this is the
+    // closest equivalent that I had available without diverging too
+    // much.
+    FunctionReturn(Value),
 }
 
 #[derive(Debug)]