1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibJS: Convert IteratorNext AO to ThrowCompletionOr

This commit is contained in:
Timothy Flynn 2021-10-20 08:44:30 -04:00 committed by Linus Groh
parent f4c8f2102f
commit c981d7b9bd
4 changed files with 31 additions and 30 deletions

View file

@ -359,12 +359,12 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const
auto* array = Array::create(global_object, 0);
while (!iterator_done) {
auto next_object = iterator_next(*iterator);
if (!next_object) {
auto next_object_or_error = iterator_next(*iterator);
if (next_object_or_error.is_throw_completion()) {
iterator_done = true;
VERIFY(exception());
return JS::throw_completion(exception()->value());
return JS::throw_completion(next_object_or_error.release_error().value());
}
auto* next_object = next_object_or_error.release_value();
auto done_property = TRY(next_object->get(names.done));
if (done_property.to_boolean()) {
@ -378,12 +378,12 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const
value = array;
} else if (!iterator_done) {
auto next_object = iterator_next(*iterator);
if (!next_object) {
auto next_object_or_error = iterator_next(*iterator);
if (next_object_or_error.is_throw_completion()) {
iterator_done = true;
VERIFY(exception());
return JS::throw_completion(exception()->value());
return JS::throw_completion(next_object_or_error.release_error().value());
}
auto* next_object = next_object_or_error.release_value();
auto done_property = TRY(next_object->get(names.done));
if (done_property.to_boolean()) {