1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +00:00

LibJS: Convert IteratorValue AO to ThrowCompletionOr

This commit is contained in:
Timothy Flynn 2021-10-20 09:05:52 -04:00 committed by Linus Groh
parent a64752cd34
commit 7b4814f74c
8 changed files with 20 additions and 21 deletions

View file

@ -57,9 +57,7 @@ ThrowCompletionOr<MarkedValueList> iterable_to_list_of_type(GlobalObject& global
// b. If next is not false, then
if (next) {
// i. Let nextValue be ? IteratorValue(next).
auto next_value = iterator_value(global_object, *iterator_result);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
auto next_value = TRY(iterator_value(global_object, *iterator_result));
// ii. If Type(nextValue) is not an element of elementTypes, then
if (auto type = to_option_type(next_value); !type.has_value() || !element_types.contains_slow(*type)) {
// 1. Let completion be ThrowCompletion(a newly created TypeError object).

View file

@ -508,9 +508,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(CalendarPrototype::fields)
break;
// i. Let nextValue be ? IteratorValue(next).
auto next_value = iterator_value(global_object, *next);
if (vm.exception())
return {};
auto next_value = TRY_OR_DISCARD(iterator_value(global_object, *next));
// ii. If Type(nextValue) is not String, then
if (!next_value.is_string()) {