diff --git a/crates/js/src/vm.rs b/crates/js/src/vm.rs index ec7dc59..dc05b88 100644 --- a/crates/js/src/vm.rs +++ b/crates/js/src/vm.rs @@ -2476,33 +2476,9 @@ impl Vm { // Create {value, done: false} result. let result = self.make_iterator_result(yield_val, false); - // If this was the only frame, return the result. - if self.frames.is_empty() { - return Ok(result); - } - - // Otherwise, write the result into the generator_next caller's dst. - let caller_fi = self.frames.len() - 1; - let return_reg = self.frames[caller_fi].base; - // The return_reg is stored on the popped frame — but we stored - // the gen_ref there. We need to use the gen_next's return location. - // Actually, the generator frame's return_reg IS where the result goes. - let old_return_reg = self.registers.len().min(saved_base + reg_count); // just use gen_ref loc - let _ = old_return_reg; - let _ = return_reg; - // The result should go to the return register that was set when - // we pushed the frame. Since we already popped, we stored it at - // frame.return_reg. Let's look at where that was. - // Actually: the generator resumes via run_generator which pushed - // a frame with return_reg set. When Yield pops that frame, it needs - // to write the result to that return_reg. But the frame is already popped. - // Let's re-read it before popping. - // (This path handles generators called from the run loop.) - - // Actually, generators always run via run_generator which uses - // an isolated frame stack. After Yield pops, the frame stack is empty - // and we fall out of run() with the returned result. - // So this unreachable path should not happen. + // Generators always run via run_generator which uses an isolated + // frame stack. After Yield pops the generator frame, the stack is + // empty and we return the {value, done} result to run_generator. return Ok(result); }