added stack overflow error

This commit is contained in:
Moritz Gmeiner 2024-09-01 20:47:42 +02:00
commit 6386df22c0
3 changed files with 10 additions and 8 deletions

View file

@ -206,7 +206,7 @@ impl Eval for Expr {
let mut methods: FxHashMap<String, Value> = FxHashMap::default();
// this is the scope "this" will get injected in
env.enter_scope();
env.enter_scope()?;
for method_expr in method_exprs.iter() {
let method = method_expr.eval(env)?;
@ -280,7 +280,7 @@ impl Eval for Stmt {
env.define(name.clone(), initializer);
}
Stmt::Block { statements } => {
env.enter_scope();
env.enter_scope()?;
for statement in statements {
if let Err(err) = statement.eval(env) {
env.exit_scope();
@ -318,7 +318,7 @@ pub fn call_fun(fun: Rc<LoxFunction>, env: &mut Environment) -> EvalResult<Value
});
}
env.enter_scope();
env.enter_scope()?;
env.define(fun.name(), Value::Function(fun.clone()));