1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

LibJS: Make PrimitiveString::create() infallible

Work towards #20449.
This commit is contained in:
Andreas Kling 2023-08-08 18:25:57 +02:00
parent b7b02693b9
commit 1a27c525d5
69 changed files with 185 additions and 198 deletions

View file

@ -247,11 +247,11 @@ ThrowCompletionOr<Value> NumberFormat::use_grouping_to_value(VM& vm) const
{
switch (m_use_grouping) {
case UseGrouping::Always:
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "always"sv));
return PrimitiveString::create(vm, "always"_string);
case UseGrouping::Auto:
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "auto"sv));
return PrimitiveString::create(vm, "auto"_string);
case UseGrouping::Min2:
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "min2"sv));
return PrimitiveString::create(vm, "min2"_string);
case UseGrouping::False:
return Value(false);
default:
@ -947,7 +947,7 @@ ThrowCompletionOr<Array*> format_numeric_to_parts(VM& vm, NumberFormat& number_f
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, MUST_OR_THROW_OOM(PrimitiveString::create(vm, part.type))));
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
@ -1936,13 +1936,13 @@ ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM& vm, NumberFormat& nu
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, MUST_OR_THROW_OOM(PrimitiveString::create(vm, part.type))));
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
// d. Perform ! CreateDataPropertyOrThrow(O, "source", part.[[Source]]).
MUST(object->create_data_property_or_throw(vm.names.source, MUST_OR_THROW_OOM(PrimitiveString::create(vm, part.source))));
MUST(object->create_data_property_or_throw(vm.names.source, PrimitiveString::create(vm, part.source)));
// e. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O).
MUST(result->create_data_property_or_throw(n, object));