Skip to content

Commit e2a0b6d

Browse files
committed
Close iterator after generator return while array destructuring
1 parent be055a3 commit e2a0b6d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

boa_engine/src/bytecompiler/declaration/declaration_pattern.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ impl ByteCompiler<'_, '_> {
190190

191191
let exit = self.jump();
192192
self.patch_handler(handler_index);
193+
let generator_return_handle = self.in_generator.then(|| self.push_handler());
193194
self.emit_opcode(Opcode::Exception);
194195
self.emit_opcode(Opcode::PushTrue);
196+
if let Some(generator_return_handle) = generator_return_handle {
197+
let is_not_generator_exit = self.jump();
198+
self.patch_handler(generator_return_handle);
199+
self.emit_opcode(Opcode::PushFalse);
200+
self.patch_jump(is_not_generator_exit);
201+
}
195202
self.patch_jump(exit);
196203

197204
self.current_stack_value_count += 2;

0 commit comments

Comments
 (0)