Skip to content

Commit

Permalink
Close iterator after generator return while array desctructoring
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 22, 2023
1 parent 91986f1 commit acff3ff
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,16 @@ 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);

let iterator_close_handler = self.push_handler();
Expand Down

0 comments on commit acff3ff

Please sign in to comment.