Skip to content

Commit

Permalink
Close iterator after generator return while array destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 29, 2023
1 parent be055a3 commit e2a0b6d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,15 @@ impl ByteCompiler<'_, '_> {

let exit = self.jump();
self.patch_handler(handler_index);
let generator_return_handle = self.in_generator.then(|| self.push_handler());
self.emit_opcode(Opcode::Exception);
self.emit_opcode(Opcode::PushTrue);
if let Some(generator_return_handle) = generator_return_handle {
let is_not_generator_exit = self.jump();
self.patch_handler(generator_return_handle);
self.emit_opcode(Opcode::PushFalse);
self.patch_jump(is_not_generator_exit);
}
self.patch_jump(exit);

self.current_stack_value_count += 2;
Expand Down

0 comments on commit e2a0b6d

Please sign in to comment.