mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:07:46 +00:00
LibJS: Implement IteratorClose with Completions and align to the spec
This commit is contained in:
parent
04b4307b3d
commit
ec54a7b5b0
8 changed files with 97 additions and 79 deletions
|
@ -63,8 +63,7 @@ ThrowCompletionOr<MarkedValueList> iterable_to_list_of_type(GlobalObject& global
|
|||
// 1. Let completion be ThrowCompletion(a newly created TypeError object).
|
||||
auto completion = vm.throw_completion<TypeError>(global_object, ErrorType::IterableToListOfTypeInvalidValue, next_value.to_string_without_side_effects());
|
||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||
iterator_close(*iterator_record);
|
||||
return completion;
|
||||
return iterator_close(*iterator_record, move(completion));
|
||||
}
|
||||
// iii. Append nextValue to the end of the List values.
|
||||
values.append(next_value);
|
||||
|
|
|
@ -513,31 +513,28 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(CalendarPrototype::fields)
|
|||
// ii. If Type(nextValue) is not String, then
|
||||
if (!next_value.is_string()) {
|
||||
// 1. Let completion be ThrowCompletion(a newly created TypeError object).
|
||||
vm.throw_exception<TypeError>(global_object, ErrorType::TemporalInvalidCalendarFieldValue, next_value.to_string_without_side_effects());
|
||||
auto completion = vm.throw_completion<TypeError>(global_object, ErrorType::TemporalInvalidCalendarFieldValue, next_value.to_string_without_side_effects());
|
||||
|
||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||
iterator_close(*iterator_record);
|
||||
return {};
|
||||
return TRY_OR_DISCARD(iterator_close(*iterator_record, move(completion)));
|
||||
}
|
||||
|
||||
// iii. If fieldNames contains nextValue, then
|
||||
if (field_names.contains_slow(next_value)) {
|
||||
// 1. Let completion be ThrowCompletion(a newly created RangeError object).
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalDuplicateCalendarField, next_value.as_string().string());
|
||||
auto completion = vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDuplicateCalendarField, next_value.as_string().string());
|
||||
|
||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||
iterator_close(*iterator_record);
|
||||
return {};
|
||||
return TRY_OR_DISCARD(iterator_close(*iterator_record, move(completion)));
|
||||
}
|
||||
|
||||
// iv. If nextValue is not one of "year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", then
|
||||
if (!next_value.as_string().string().is_one_of("year"sv, "month"sv, "monthCode"sv, "day"sv, "hour"sv, "minute"sv, "second"sv, "millisecond"sv, "microsecond"sv, "nanosecond"sv)) {
|
||||
// 1. Let completion be ThrowCompletion(a newly created RangeError object).
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFieldName, next_value.as_string().string());
|
||||
auto completion = vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFieldName, next_value.as_string().string());
|
||||
|
||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||
iterator_close(*iterator_record);
|
||||
return {};
|
||||
return TRY_OR_DISCARD(iterator_close(*iterator_record, move(completion)));
|
||||
}
|
||||
|
||||
// v. Append nextValue to the end of the List fieldNames.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue