mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
LibJS: Make Value::to_string_without_side_effects() infallible
Work towards #20449.
This commit is contained in:
parent
b8f78c0adc
commit
97ebfd9f0f
69 changed files with 182 additions and 182 deletions
|
@ -62,7 +62,7 @@ ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(VM& vm, Value it
|
|||
// 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).
|
||||
auto completion = vm.throw_completion<TypeError>(ErrorType::IterableToListOfTypeInvalidValue, TRY_OR_THROW_OOM(vm, next_value.to_string_without_side_effects()));
|
||||
auto completion = vm.throw_completion<TypeError>(ErrorType::IterableToListOfTypeInvalidValue, next_value.to_string_without_side_effects());
|
||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||
return iterator_close(vm, iterator_record, move(completion));
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ ThrowCompletionOr<Object*> calendar_merge_fields(VM& vm, Object& calendar, Objec
|
|||
|
||||
// 4. If Type(result) is not Object, throw a TypeError exception.
|
||||
if (!result.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, result.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, result.to_string_without_side_effects());
|
||||
|
||||
// 5. Return result.
|
||||
return &result.as_object();
|
||||
|
|
|
@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_from_fields)
|
|||
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
||||
auto fields = vm.argument(0);
|
||||
if (!fields.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, fields.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_string_without_side_effects());
|
||||
|
||||
// 5. Set options to ? GetOptionsObject(options).
|
||||
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||
|
@ -118,7 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year_month_from_fields)
|
|||
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
||||
auto fields = vm.argument(0);
|
||||
if (!fields.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, fields.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_string_without_side_effects());
|
||||
|
||||
// 5. Set options to ? GetOptionsObject(options).
|
||||
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||
|
@ -144,7 +144,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_day_from_fields)
|
|||
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
||||
auto fields = vm.argument(0);
|
||||
if (!fields.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, fields.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_string_without_side_effects());
|
||||
|
||||
// 5. Set options to ? GetOptionsObject(options).
|
||||
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||
|
@ -553,7 +553,7 @@ JS_DEFINE_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).
|
||||
auto completion = vm.throw_completion<TypeError>(ErrorType::TemporalInvalidCalendarFieldValue, TRY_OR_THROW_OOM(vm, next_value.to_string_without_side_effects()));
|
||||
auto completion = vm.throw_completion<TypeError>(ErrorType::TemporalInvalidCalendarFieldValue, next_value.to_string_without_side_effects());
|
||||
|
||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||
return *TRY(iterator_close(vm, iterator_record, move(completion)));
|
||||
|
|
|
@ -305,7 +305,7 @@ ThrowCompletionOr<PartialDurationRecord> to_temporal_partial_duration_record(VM&
|
|||
// 1. If Type(temporalDurationLike) is not Object, then
|
||||
if (!temporal_duration_like.is_object()) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_duration_like.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_duration_like.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
// 2. Let result be a new partial Duration Record with each field set to undefined.
|
||||
|
|
|
@ -408,7 +408,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with)
|
|||
// 3. If Type(temporalDateLike) is not Object, then
|
||||
if (!temporal_date_like.is_object()) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_date_like.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_date_like.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateLike).
|
||||
|
|
|
@ -380,7 +380,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with)
|
|||
// 3. If Type(temporalDateTimeLike) is not Object, then
|
||||
if (!temporal_date_time_like.is_object()) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_date_time_like.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_date_time_like.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateTimeLike).
|
||||
|
|
|
@ -95,7 +95,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::with)
|
|||
// 3. If Type(temporalMonthDayLike) is not Object, then
|
||||
if (!temporal_month_day_like.is_object()) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_month_day_like.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_month_day_like.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalMonthDayLike).
|
||||
|
|
|
@ -174,7 +174,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with)
|
|||
// 3. If Type(temporalTimeLike) is not Object, then
|
||||
if (!temporal_time_like_argument.is_object()) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_time_like_argument.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_time_like_argument.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
auto& temporal_time_like = temporal_time_like_argument.as_object();
|
||||
|
|
|
@ -206,7 +206,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::with)
|
|||
// 3. If Type(temporalYearMonthLike) is not Object, then
|
||||
if (!temporal_year_month_like.is_object()) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_year_month_like.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_year_month_like.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalYearMonthLike).
|
||||
|
|
|
@ -754,7 +754,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
|||
// 3. If Type(temporalZonedDateTimeLike) is not Object, then
|
||||
if (!temporal_zoned_date_time_like.is_object()) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_zoned_date_time_like.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_zoned_date_time_like.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalZonedDateTimeLike).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue