fix: nested return
This commit is contained in:
+10
-5
@@ -1166,11 +1166,11 @@ impl Runtime {
|
||||
|
||||
pub(super) fn force_tos(&mut self) -> Action {
|
||||
loop {
|
||||
let run = self.arena.mutate_root(|_mc, root| {
|
||||
let (run, target_depth) = self.arena.mutate_root(|_mc, root| {
|
||||
let thunk = root.stack.tos_mut().expect("stack underflow");
|
||||
|
||||
let Some(thunk_state) = thunk.as_gc::<Thunk>() else {
|
||||
return false;
|
||||
return (false, 0);
|
||||
};
|
||||
match *thunk_state.borrow() {
|
||||
ThunkState::Pending { ip, env } => {
|
||||
@@ -1182,12 +1182,12 @@ impl Runtime {
|
||||
.expect("call stack overflow");
|
||||
self.pc = ip;
|
||||
root.current_env = Some(env);
|
||||
true
|
||||
(true, root.frames.len())
|
||||
}
|
||||
ThunkState::Apply { .. } => todo!("force_tos"),
|
||||
ThunkState::Evaluated(val) => {
|
||||
*thunk = val;
|
||||
false
|
||||
(false, 0)
|
||||
}
|
||||
ThunkState::Blackhole => todo!("force_tos"),
|
||||
}
|
||||
@@ -1199,7 +1199,12 @@ impl Runtime {
|
||||
self.check_gc();
|
||||
match self.execute_one() {
|
||||
Action::Continue => (),
|
||||
Action::Return => break,
|
||||
Action::Return => {
|
||||
let current_depth = self.arena.mutate_root(|_, root| root.frames.len());
|
||||
if current_depth < target_depth {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// FIXME: poison thunk
|
||||
Action::Done(err @ Err(_)) => return Action::Done(err),
|
||||
Action::Done(Ok(_)) => unreachable!(),
|
||||
|
||||
Reference in New Issue
Block a user