diff --git a/src/interpreter/environment.rs b/src/interpreter/environment.rs index 97e1e46..824bf50 100644 --- a/src/interpreter/environment.rs +++ b/src/interpreter/environment.rs @@ -5,7 +5,10 @@ use crate::{ tokens::Token, }; -use super::{Value, native_fn::{self, NativeFunction}}; +use super::{ + native_fn::{self, NativeFunction}, + Value, +}; /// A mutable reference to an environment. pub(super) type EnvironmentRef = Rc>; @@ -127,7 +130,7 @@ impl Environment { pub fn read(&self, name: &str) -> Value { match self.values.get(name) { Some(Some(v)) => v.clone(), - _ => panic!("Symbol {name} does not exist"), + _ => panic!("Symbol {name} does not exist ({:?})", self.values.keys()), } } diff --git a/src/interpreter/functions.rs b/src/interpreter/functions.rs index 7fd07dc..b58d866 100644 --- a/src/interpreter/functions.rs +++ b/src/interpreter/functions.rs @@ -77,13 +77,13 @@ impl Callable for Function { InterpreterFlowControl::Result(_) => (), InterpreterFlowControl::Return(v) if !self.is_initializer => return Ok(v), InterpreterFlowControl::Return(_) => { - return Ok(itpr_state.environment.borrow().read("this")) + return Ok(self.env.borrow().read("this")) } _ => panic!("unexpected flow control {:?}", result), } } if self.is_initializer { - Ok(itpr_state.environment.borrow().read("this")) + Ok(self.env.borrow().read("this")) } else { Ok(Value::Nil) }