mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
LibJS: Make PrimitiveString::utf8_string() infallible
Work towards #20449.
This commit is contained in:
parent
7849950383
commit
c084269e5f
29 changed files with 79 additions and 93 deletions
|
@ -146,7 +146,7 @@ ThrowCompletionOr<Value> get_option(VM& vm, Object const& options, PropertyKey c
|
|||
if (!values.is_empty()) {
|
||||
// NOTE: Every location in the spec that invokes GetOption with type=boolean also has values=undefined.
|
||||
VERIFY(value.is_string());
|
||||
if (auto value_string = TRY(value.as_string().utf8_string()); !values.contains_slow(value_string))
|
||||
if (auto value_string = value.as_string().utf8_string(); !values.contains_slow(value_string))
|
||||
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, value_string, property.as_string());
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ ThrowCompletionOr<Optional<String>> get_temporal_unit(VM& vm, Object const& norm
|
|||
|
||||
auto value = option_value.is_undefined()
|
||||
? Optional<String> {}
|
||||
: TRY(option_value.as_string().utf8_string());
|
||||
: option_value.as_string().utf8_string();
|
||||
|
||||
// 11. If value is listed in the Plural column of Table 13, then
|
||||
for (auto const& row : temporal_units) {
|
||||
|
|
|
@ -131,7 +131,7 @@ ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vect
|
|||
Vector<String> result;
|
||||
TRY_OR_THROW_OOM(vm, result.try_ensure_capacity(list.size()));
|
||||
for (auto& value : list)
|
||||
result.unchecked_append(TRY(value.as_string().utf8_string()));
|
||||
result.unchecked_append(value.as_string().utf8_string());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -559,7 +559,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields)
|
|||
return *TRY(iterator_close(vm, iterator_record, move(completion)));
|
||||
}
|
||||
|
||||
auto next_value_string = TRY(next_value.as_string().utf8_string());
|
||||
auto next_value_string = next_value.as_string().utf8_string();
|
||||
|
||||
// iii. If fieldNames contains nextValue, then
|
||||
if (field_names.contains_slow(next_value)) {
|
||||
|
|
|
@ -176,7 +176,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item
|
|||
offset_behavior = OffsetBehavior::Wall;
|
||||
} else {
|
||||
// NOTE: Not in the spec, since it directly assigns to offsetString in step i, but we can't do it there as it's a type mismatch.
|
||||
offset_string = TRY(offset_string_value.as_string().utf8_string());
|
||||
offset_string = offset_string_value.as_string().utf8_string();
|
||||
}
|
||||
|
||||
// l. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
|
||||
|
|
|
@ -801,7 +801,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
|||
|
||||
// 18. Assert: Type(offsetString) is String.
|
||||
VERIFY(offset_string_value.is_string());
|
||||
auto offset_string = TRY(offset_string_value.as_string().utf8_string());
|
||||
auto offset_string = offset_string_value.as_string().utf8_string();
|
||||
|
||||
// 19. Let dateTimeResult be ? InterpretTemporalDateTimeFields(calendar, fields, options).
|
||||
auto date_time_result = TRY(interpret_temporal_date_time_fields(vm, calendar, *fields, options));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue