diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index f26f1aee36..b94c597824 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -2682,7 +2682,7 @@ void @class_name@::initialize(JS::Realm& realm) } generator.append(R"~~~( - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(JS::PrimitiveString::create(vm, "@namespaced_name@"sv)), JS::Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "@namespaced_name@"_string), JS::Attribute::Configurable); )~~~"); if (!is_global_interface) { @@ -3888,7 +3888,7 @@ void @prototype_class@::initialize(JS::Realm& realm) auto& vm = this->vm(); Base::initialize(realm); define_native_function(realm, vm.names.next, next, 0, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(JS::PrimitiveString::create(vm, "Iterator"sv)), JS::Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "Iterator"_string), JS::Attribute::Configurable); } static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index ddd3dd1570..52441b9619 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -196,7 +196,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea m_constructors.set("@interface_name@"sv, constructor); prototype->define_direct_property(vm.names.constructor, constructor.ptr(), JS::Attribute::Writable | JS::Attribute::Configurable); - constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@interface_name@"sv).release_allocated_value_but_fixme_should_propagate_errors(), JS::Attribute::Configurable); + constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@interface_name@"_string), JS::Attribute::Configurable); )~~~"); if (legacy_constructor.has_value()) { @@ -206,7 +206,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); m_constructors.set("@legacy_interface_name@"sv, legacy_constructor); - legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"sv).release_allocated_value_but_fixme_should_propagate_errors(), JS::Attribute::Configurable);)~~~"); + legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"_string), JS::Attribute::Configurable);)~~~"); } gen.append(R"~~~( diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 53e0b3ea76..8e396a3742 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -152,7 +152,7 @@ static ThrowCompletionOr not_(VM&, Value value) static ThrowCompletionOr typeof_(VM& vm, Value value) { - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, value.typeof())); + return PrimitiveString::create(vm, value.typeof()); } #define JS_DEFINE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \ @@ -1427,7 +1427,7 @@ ThrowCompletionOr TypeofVariable::execute_impl(Bytecode::Interpreter& inte // 2. If val is a Reference Record, then // a. If IsUnresolvableReference(val) is true, return "undefined". if (reference.is_unresolvable()) { - interpreter.accumulator() = MUST_OR_THROW_OOM(PrimitiveString::create(vm, "undefined"sv)); + interpreter.accumulator() = PrimitiveString::create(vm, "undefined"_string); return {}; } @@ -1436,7 +1436,7 @@ ThrowCompletionOr TypeofVariable::execute_impl(Bytecode::Interpreter& inte // 4. NOTE: This step is replaced in section B.3.6.3. // 5. Return a String according to Table 41. - interpreter.accumulator() = MUST_OR_THROW_OOM(PrimitiveString::create(vm, value.typeof())); + interpreter.accumulator() = PrimitiveString::create(vm, value.typeof()); return {}; } @@ -1444,7 +1444,7 @@ ThrowCompletionOr TypeofLocal::execute_impl(Bytecode::Interpreter& interpr { auto& vm = interpreter.vm(); auto const& value = vm.running_execution_context().local_variables[m_index]; - interpreter.accumulator() = MUST_OR_THROW_OOM(PrimitiveString::create(vm, value.typeof())); + interpreter.accumulator() = PrimitiveString::create(vm, value.typeof()); return {}; } diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp index 9fdf5503b5..effb701cab 100644 --- a/Userland/Libraries/LibJS/Console.cpp +++ b/Userland/Libraries/LibJS/Console.cpp @@ -33,7 +33,7 @@ ThrowCompletionOr Console::assert_() return js_undefined(); // 2. Let message be a string without any formatting specifiers indicating generically an assertion failure (such as "Assertion failed"). - auto message = MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Assertion failed"sv)); + auto message = PrimitiveString::create(vm, "Assertion failed"_string); // NOTE: Assemble `data` from the function arguments. MarkedVector data { vm.heap() }; diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp index 7fc91f6f41..488c5b8cc5 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp @@ -20,7 +20,7 @@ void AggregateErrorPrototype::initialize(Realm& realm) auto& vm = this->vm(); Base::initialize(realm); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.name, MUST(PrimitiveString::create(vm, "AggregateError"sv)), attr); + define_direct_property(vm.names.name, PrimitiveString::create(vm, "AggregateError"_string), attr); define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); } diff --git a/Userland/Libraries/LibJS/Runtime/Array.h b/Userland/Libraries/LibJS/Runtime/Array.h index 8c5dda2b48..4b010a4615 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.h +++ b/Userland/Libraries/LibJS/Runtime/Array.h @@ -38,19 +38,6 @@ public: return Array::create_from(realm, values); } - // Non-standard but equivalent to CreateArrayFromList. - template Callback> - static ThrowCompletionOr> try_create_from(VM& vm, Realm& realm, ReadonlySpan elements, Callback map_fn) - { - auto values = MarkedVector { realm.heap() }; - TRY_OR_THROW_OOM(vm, values.try_ensure_capacity(elements.size())); - - for (auto const& element : elements) - TRY_OR_THROW_OOM(vm, values.try_append(TRY(map_fn(element)))); - - return Array::create_from(realm, values); - } - virtual ~Array() override = default; virtual ThrowCompletionOr> internal_get_own_property(PropertyKey const&) const override; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp index 26bbc3d694..75efd03c35 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp @@ -27,7 +27,7 @@ void ArrayIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Array Iterator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Array Iterator"_string), Attribute::Configurable); } // 23.1.5.2.1 %ArrayIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp index badce06ab5..174ff51c91 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp @@ -28,7 +28,7 @@ void AsyncGeneratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.throw_, throw_, 1, attr); // 27.6.1.5 AsyncGenerator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgenerator-prototype-tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "AsyncGenerator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "AsyncGenerator"_string), Attribute::Configurable); } // 27.6.3.3 AsyncGeneratorValidate ( generator, generatorBrand ), https://tc39.es/ecma262/#sec-asyncgeneratorvalidate diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp index b3bd9cf5b8..423beec7e9 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp @@ -147,7 +147,7 @@ void AtomicsObject::initialize(Realm& realm) define_native_function(realm, vm.names.xor_, xor_, 3, attr); // 25.4.15 Atomics [ @@toStringTag ], https://tc39.es/ecma262/#sec-atomics-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Atomics"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Atomics"_string), Attribute::Configurable); } // 25.4.3 Atomics.add ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.add diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 7c182bc6b8..43229fb915 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -950,7 +950,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_date_string) // 3. If tv is NaN, return "Invalid Date". if (isnan(time)) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Invalid Date"sv)); + return PrimitiveString::create(vm, "Invalid Date"_string); // 4. Let t be LocalTime(tv). // 5. Return DateString(t). @@ -996,7 +996,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_date_string) // 2. If x is NaN, return "Invalid Date". if (isnan(time)) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Invalid Date"sv)); + return PrimitiveString::create(vm, "Invalid Date"_string); // 3. Let dateFormat be ? CreateDateTimeFormat(%DateTimeFormat%, locales, options, "date", "date"). auto date_format = TRY(Intl::create_date_time_format(vm, realm.intrinsics().intl_date_time_format_constructor(), locales, options, Intl::OptionRequired::Date, Intl::OptionDefaults::Date)); @@ -1020,7 +1020,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_string) // 2. If x is NaN, return "Invalid Date". if (isnan(time)) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Invalid Date"sv)); + return PrimitiveString::create(vm, "Invalid Date"_string); // 3. Let dateFormat be ? CreateDateTimeFormat(%DateTimeFormat%, locales, options, "any", "all"). auto date_format = TRY(Intl::create_date_time_format(vm, realm.intrinsics().intl_date_time_format_constructor(), locales, options, Intl::OptionRequired::Any, Intl::OptionDefaults::All)); @@ -1044,7 +1044,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_time_string) // 2. If x is NaN, return "Invalid Date". if (isnan(time)) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Invalid Date"sv)); + return PrimitiveString::create(vm, "Invalid Date"_string); // 3. Let timeFormat be ? CreateDateTimeFormat(%DateTimeFormat%, locales, options, "time", "time"). auto time_format = TRY(Intl::create_date_time_format(vm, realm.intrinsics().intl_date_time_format_constructor(), locales, options, Intl::OptionRequired::Time, Intl::OptionDefaults::Time)); @@ -1198,7 +1198,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_time_string) // 3. If tv is NaN, return "Invalid Date". if (isnan(time)) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Invalid Date"sv)); + return PrimitiveString::create(vm, "Invalid Date"_string); // 4. Let t be LocalTime(tv). // 5. Return the string-concatenation of TimeString(t) and TimeZoneString(tv). @@ -1215,7 +1215,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string) // 3. If tv is NaN, return "Invalid Date". if (isnan(time)) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Invalid Date"sv)); + return PrimitiveString::create(vm, "Invalid Date"_string); // 4. Let weekday be the Name of the entry in Table 62 with the Number WeekDay(tv). auto weekday = short_day_names[week_day(time)]; diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index d21380004d..b3a62a77ce 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -24,7 +24,7 @@ void ErrorPrototype::initialize(Realm& realm) auto& vm = this->vm(); Base::initialize(realm); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.name, MUST(PrimitiveString::create(vm, "Error"sv)), attr); + define_direct_property(vm.names.name, PrimitiveString::create(vm, "Error"_string), attr); define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); define_native_function(realm, vm.names.toString, to_string, 0, attr); // Non standard property "stack" @@ -122,19 +122,19 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter) return TRY(this_object.create_data_property_or_throw(vm.names.stack, vm.argument(0))); } -#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - PrototypeName::PrototypeName(Realm& realm) \ - : PrototypeObject(realm.intrinsics().error_prototype()) \ - { \ - } \ - \ - void PrototypeName::initialize(Realm& realm) \ - { \ - auto& vm = this->vm(); \ - Base::initialize(realm); \ - u8 attr = Attribute::Writable | Attribute::Configurable; \ - define_direct_property(vm.names.name, MUST(PrimitiveString::create(vm, #ClassName##sv)), attr); \ - define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); \ +#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ + PrototypeName::PrototypeName(Realm& realm) \ + : PrototypeObject(realm.intrinsics().error_prototype()) \ + { \ + } \ + \ + void PrototypeName::initialize(Realm& realm) \ + { \ + auto& vm = this->vm(); \ + Base::initialize(realm); \ + u8 attr = Attribute::Writable | Attribute::Configurable; \ + define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName##_string), attr); \ + define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index a65f954411..0398cc30ac 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -168,7 +168,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) // 4. If Type(func) is Object and IsCallable(func) is true, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction. // NOTE: ProxyObject, BoundFunction, WrappedFunction - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "function () { [native code] }"sv)); + return PrimitiveString::create(vm, "function () { [native code] }"_string); } // 20.2.3.6 Function.prototype [ @@hasInstance ] ( V ), https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp index 93da3bfe2d..b8a64c79ce 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp @@ -23,7 +23,7 @@ void GeneratorFunctionPrototype::initialize(Realm& realm) // 27.3.3.2 GeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype define_direct_property(vm.names.prototype, realm.intrinsics().generator_prototype(), Attribute::Configurable); // 27.3.3.3 GeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "GeneratorFunction"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "GeneratorFunction"_string), Attribute::Configurable); } } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp index a56c4b3b01..835d46c380 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp @@ -24,7 +24,7 @@ void GeneratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.throw_, throw_, 1, attr); // 27.5.1.5 Generator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generator.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Generator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Generator"_string), Attribute::Configurable); } // 27.5.1.2 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.next diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp index 6b336d8e64..95158947b5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -88,7 +88,7 @@ static ThrowCompletionOr initialize_collator(VM& vm, Collator& collat // 24. If relevantExtensionKeys contains "kn", then if (relevant_extension_keys.span().contains_slow("kn"sv) && result.kn.has_value()) { // a. Set collator.[[Numeric]] to SameValue(r.[[kn]], "true"). - collator.set_numeric(same_value(PrimitiveString::create(vm, result.kn.release_value()), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "true"sv)))); + collator.set_numeric(same_value(PrimitiveString::create(vm, result.kn.release_value()), PrimitiveString::create(vm, "true"_string))); } // 25. If relevantExtensionKeys contains "kf", then @@ -105,14 +105,14 @@ static ThrowCompletionOr initialize_collator(VM& vm, Collator& collat // a. If usage is "sort", then if (collator.usage() == Collator::Usage::Sort) { // i. Let sensitivity be "variant". - sensitivity = MUST_OR_THROW_OOM(PrimitiveString::create(vm, "variant"sv)); + sensitivity = PrimitiveString::create(vm, "variant"_string); } // b. Else, else { // i. Let dataLocale be r.[[dataLocale]]. // ii. Let dataLocaleData be localeData.[[]]. // iii. Let sensitivity be dataLocaleData.[[sensitivity]]. - sensitivity = MUST_OR_THROW_OOM(PrimitiveString::create(vm, "base"sv)); + sensitivity = PrimitiveString::create(vm, "base"_string); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp index 84408151b2..59eb176d31 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp @@ -24,7 +24,7 @@ void CollatorPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 10.3.2 Intl.Collator.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.collator.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.Collator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Collator"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr); @@ -76,12 +76,12 @@ JS_DEFINE_NATIVE_FUNCTION(CollatorPrototype::resolved_options) // d. If v is not undefined, then // i. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, collator->locale()))); - MUST(options->create_data_property_or_throw(vm.names.usage, MUST_OR_THROW_OOM(PrimitiveString::create(vm, collator->usage_string())))); - MUST(options->create_data_property_or_throw(vm.names.sensitivity, MUST_OR_THROW_OOM(PrimitiveString::create(vm, collator->sensitivity_string())))); + MUST(options->create_data_property_or_throw(vm.names.usage, PrimitiveString::create(vm, collator->usage_string()))); + MUST(options->create_data_property_or_throw(vm.names.sensitivity, PrimitiveString::create(vm, collator->sensitivity_string()))); MUST(options->create_data_property_or_throw(vm.names.ignorePunctuation, Value(collator->ignore_punctuation()))); MUST(options->create_data_property_or_throw(vm.names.collation, PrimitiveString::create(vm, collator->collation()))); MUST(options->create_data_property_or_throw(vm.names.numeric, Value(collator->numeric()))); - MUST(options->create_data_property_or_throw(vm.names.caseFirst, MUST_OR_THROW_OOM(PrimitiveString::create(vm, collator->case_first_string())))); + MUST(options->create_data_property_or_throw(vm.names.caseFirst, PrimitiveString::create(vm, collator->case_first_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp index da1865e230..e578502592 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp @@ -789,7 +789,7 @@ ThrowCompletionOr format_date_time_to_parts(VM& vm, DateTimeFormat& date 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)))); @@ -1106,13 +1106,13 @@ ThrowCompletionOr format_date_time_range_to_parts(VM& vm, DateTimeFormat 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 ! CreateDataProperty(result, ! ToString(n), O). MUST(result->create_data_property_or_throw(n, object)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp index a3ba82e2e3..b5c336e459 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp @@ -26,7 +26,7 @@ void DateTimeFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 11.3.2 Intl.DateTimeFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.DateTimeFormat"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DateTimeFormat"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable); @@ -177,7 +177,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) MUST(options->create_data_property_or_throw(vm.names.timeZone, PrimitiveString::create(vm, date_time_format->time_zone()))); if (date_time_format->has_hour_cycle()) { - MUST(options->create_data_property_or_throw(vm.names.hourCycle, MUST_OR_THROW_OOM(PrimitiveString::create(vm, date_time_format->hour_cycle_string())))); + MUST(options->create_data_property_or_throw(vm.names.hourCycle, PrimitiveString::create(vm, date_time_format->hour_cycle_string()))); switch (date_time_format->hour_cycle()) { case ::Locale::HourCycle::H11: @@ -202,7 +202,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) MUST(options->create_data_property_or_throw(property, Value(*option))); } else { auto name = ::Locale::calendar_pattern_style_to_string(*option); - MUST(options->create_data_property_or_throw(property, MUST_OR_THROW_OOM(PrimitiveString::create(vm, name)))); + MUST(options->create_data_property_or_throw(property, PrimitiveString::create(vm, name))); } return {}; @@ -210,9 +210,9 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) } if (date_time_format->has_date_style()) - MUST(options->create_data_property_or_throw(vm.names.dateStyle, MUST_OR_THROW_OOM(PrimitiveString::create(vm, date_time_format->date_style_string())))); + MUST(options->create_data_property_or_throw(vm.names.dateStyle, PrimitiveString::create(vm, date_time_format->date_style_string()))); if (date_time_format->has_time_style()) - MUST(options->create_data_property_or_throw(vm.names.timeStyle, MUST_OR_THROW_OOM(PrimitiveString::create(vm, date_time_format->time_style_string())))); + MUST(options->create_data_property_or_throw(vm.names.timeStyle, PrimitiveString::create(vm, date_time_format->time_style_string()))); // 6. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp index 43d862b963..a851732a39 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp @@ -166,7 +166,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "dateTimeField"sv); // b. Return code. - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, code)); + return PrimitiveString::create(vm, code); } // 6. Assert: type is "currency". diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 7d048c3e06..eef7f772da 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -26,7 +26,7 @@ void DisplayNamesPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 12.3.2 Intl.DisplayNames.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.DisplayNames"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DisplayNames"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.of, of, 1, attr); @@ -109,7 +109,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) } if (result.has_value()) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, result.release_value())); + return PrimitiveString::create(vm, result.release_value()); if (formatted_result.has_value()) return PrimitiveString::create(vm, formatted_result.release_value()); @@ -139,13 +139,13 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options) // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, display_names->locale()))); - MUST(options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, display_names->style_string())))); - MUST(options->create_data_property_or_throw(vm.names.type, MUST_OR_THROW_OOM(PrimitiveString::create(vm, display_names->type_string())))); - MUST(options->create_data_property_or_throw(vm.names.fallback, MUST_OR_THROW_OOM(PrimitiveString::create(vm, display_names->fallback_string())))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, display_names->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, display_names->type_string()))); + MUST(options->create_data_property_or_throw(vm.names.fallback, PrimitiveString::create(vm, display_names->fallback_string()))); // NOTE: Step 4c indicates languageDisplay must not be undefined, but it is only set when the type option is language. if (display_names->has_language_display()) - MUST(options->create_data_property_or_throw(vm.names.languageDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, display_names->language_display_string())))); + MUST(options->create_data_property_or_throw(vm.names.languageDisplay, PrimitiveString::create(vm, display_names->language_display_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp index 9dd4e132c1..53da9b1e02 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp @@ -492,14 +492,14 @@ ThrowCompletionOr> partition_duration_format_pattern(VM // ii. Else, else { // 1. Perform ! CreateDataPropertyOrThrow(nfOpts, "style", "unit"). - MUST(number_format_options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "unit"sv)))); + MUST(number_format_options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, "unit"_string))); // 2. Perform ! CreateDataPropertyOrThrow(nfOpts, "unit", numberFormatUnit). - MUST(number_format_options->create_data_property_or_throw(vm.names.unit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format_unit)))); + MUST(number_format_options->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, number_format_unit))); // 3. Perform ! CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style). auto unicode_style = ::Locale::style_to_string(static_cast<::Locale::Style>(style)); - MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, unicode_style)))); + MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, PrimitiveString::create(vm, unicode_style))); // 4. Let nf be ! Construct(%NumberFormat%, « durationFormat.[[Locale]], nfOpts »). auto* number_format = static_cast(MUST(construct(vm, realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options)).ptr()); @@ -526,7 +526,7 @@ ThrowCompletionOr> partition_duration_format_pattern(VM auto list_format_options = Object::create(realm, nullptr); // 5. Perform ! CreateDataPropertyOrThrow(lfOpts, "type", "unit"). - MUST(list_format_options->create_data_property_or_throw(vm.names.type, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "unit"sv)))); + MUST(list_format_options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, "unit"_string))); // 6. Let listStyle be durationFormat.[[Style]]. auto list_style = duration_format.style(); @@ -540,7 +540,7 @@ ThrowCompletionOr> partition_duration_format_pattern(VM auto unicode_list_style = ::Locale::style_to_string(static_cast<::Locale::Style>(list_style)); // 8. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). - MUST(list_format_options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, unicode_list_style)))); + MUST(list_format_options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, unicode_list_style))); // 9. Let lf be ! Construct(%ListFormat%, « durationFormat.[[Locale]], lfOpts »). auto* list_format = static_cast(MUST(construct(vm, realm.intrinsics().intl_list_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), list_format_options)).ptr()); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp index d56e963665..ba9d70fb98 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp @@ -25,7 +25,7 @@ void DurationFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 1.4.2 Intl.DurationFormat.prototype [ @@toStringTag ], https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.DurationFormat"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DurationFormat"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.format, format, 1, attr); @@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts) auto object = Object::create(realm, realm.intrinsics().object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(obj, "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(obj, "value", part.[[Value]]). MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, part.value))); @@ -119,27 +119,27 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options) // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, duration_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->style_string())))); - MUST(options->create_data_property_or_throw(vm.names.years, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->years_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.yearsDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->years_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.months, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->months_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.monthsDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->months_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.weeks, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->weeks_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.weeksDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->weeks_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.days, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->days_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.daysDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->days_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.hours, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->hours_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.hoursDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->hours_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.minutes, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->minutes_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.minutesDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->minutes_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.seconds, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->seconds_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.secondsDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->seconds_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.milliseconds, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->milliseconds_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.millisecondsDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->milliseconds_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.microseconds, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->microseconds_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.microsecondsDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->microseconds_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.nanoseconds, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->nanoseconds_style_string())))); - MUST(options->create_data_property_or_throw(vm.names.nanosecondsDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, duration_format->nanoseconds_display_string())))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, duration_format->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.years, PrimitiveString::create(vm, duration_format->years_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.yearsDisplay, PrimitiveString::create(vm, duration_format->years_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.months, PrimitiveString::create(vm, duration_format->months_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.monthsDisplay, PrimitiveString::create(vm, duration_format->months_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.weeks, PrimitiveString::create(vm, duration_format->weeks_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.weeksDisplay, PrimitiveString::create(vm, duration_format->weeks_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.days, PrimitiveString::create(vm, duration_format->days_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.daysDisplay, PrimitiveString::create(vm, duration_format->days_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.hours, PrimitiveString::create(vm, duration_format->hours_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.hoursDisplay, PrimitiveString::create(vm, duration_format->hours_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.minutes, PrimitiveString::create(vm, duration_format->minutes_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.minutesDisplay, PrimitiveString::create(vm, duration_format->minutes_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.seconds, PrimitiveString::create(vm, duration_format->seconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.secondsDisplay, PrimitiveString::create(vm, duration_format->seconds_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.milliseconds, PrimitiveString::create(vm, duration_format->milliseconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.millisecondsDisplay, PrimitiveString::create(vm, duration_format->milliseconds_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.microseconds, PrimitiveString::create(vm, duration_format->microseconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.microsecondsDisplay, PrimitiveString::create(vm, duration_format->microseconds_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.nanoseconds, PrimitiveString::create(vm, duration_format->nanoseconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.nanosecondsDisplay, PrimitiveString::create(vm, duration_format->nanoseconds_display_string()))); MUST(options->create_data_property_or_throw(vm.names.fractionalDigits, duration_format->has_fractional_digits() ? Value(duration_format->fractional_digits()) : js_undefined())); MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, duration_format->numbering_system()))); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp index faabf204e3..77b6333a8c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp @@ -39,7 +39,7 @@ void Intl::initialize(Realm& realm) auto& vm = this->vm(); // 8.1.1 Intl[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl-toStringTag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_intrinsic_accessor(vm.names.Collator, attr, [](auto& realm) -> Value { return realm.intrinsics().intl_collator_constructor(); }); @@ -155,9 +155,9 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of) } // 9. Return CreateArrayFromList( list ). - return MUST_OR_THROW_OOM(Array::try_create_from(vm, realm, list, [&](auto value) { + return Array::create_from(realm, list, [&](auto value) { return PrimitiveString::create(vm, value); - })); + }); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp index 7f0d62f4d9..c4d70ea0c9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp @@ -222,7 +222,7 @@ ThrowCompletionOr format_list_to_parts(VM& vm, ListFormat const& list_fo 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)))); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp index 40252f2d78..c9e620d9e2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp @@ -25,7 +25,7 @@ void ListFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 13.3.2 Intl.ListFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype-toStringTag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.ListFormat"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.ListFormat"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.format, format, 1, attr); @@ -84,8 +84,8 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options) // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, list_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.type, MUST_OR_THROW_OOM(PrimitiveString::create(vm, list_format->type_string())))); - MUST(options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, list_format->style_string())))); + MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, list_format->type_string()))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, list_format->style_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp index 422a66b408..1e0ec59743 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -62,8 +62,8 @@ static ThrowCompletionOr> create_array_from_list_or_restrict } // 2. Return ! CreateArrayFromList( list ). - return Array::try_create_from(vm, realm, list, [&vm](auto value) -> ThrowCompletionOr { - return PrimitiveString::create(vm, TRY_OR_THROW_OOM(vm, String::from_utf8(value))); + return Array::create_from(realm, list, [&vm](auto value) { + return PrimitiveString::create(vm, String::from_utf8(value).release_value()); }); } @@ -158,8 +158,8 @@ ThrowCompletionOr> time_zones_of_locale(VM& vm, StringView r quick_sort(list); // 5. Return ! CreateArrayFromList( list ). - return Array::try_create_from(vm, realm, list, [&vm](auto value) -> ThrowCompletionOr { - return PrimitiveString::create(vm, TRY_OR_THROW_OOM(vm, String::from_utf8(value))); + return Array::create_from(realm, list, [&vm](auto value) { + return PrimitiveString::create(vm, String::from_utf8(value).release_value()); }); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp index 2f5adf3076..f87bb79708 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp @@ -31,7 +31,7 @@ void LocalePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toString, to_string, 0, attr); // 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.Locale"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Locale"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.baseName, base_name, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar, {}, Attribute::Configurable); @@ -264,7 +264,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info) auto direction = MUST_OR_THROW_OOM(character_direction_of_locale(vm, locale_object)); // 5. Perform ! CreateDataPropertyOrThrow(info, "direction", dir). - MUST(info->create_data_property_or_throw(vm.names.direction, MUST_OR_THROW_OOM(PrimitiveString::create(vm, direction)))); + MUST(info->create_data_property_or_throw(vm.names.direction, PrimitiveString::create(vm, direction))); // 6. Return info. return info; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp index cb56663ddb..7013b4a43e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp @@ -247,11 +247,11 @@ ThrowCompletionOr 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 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 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)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index b583d7620b..0b955f51cc 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -26,7 +26,7 @@ void NumberFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 15.3.2 Intl.NumberFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.numberformat.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.NumberFormat"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.NumberFormat"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable); @@ -152,17 +152,17 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) // i. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, number_format->locale()))); MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, number_format->numbering_system()))); - MUST(options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->style_string())))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, number_format->style_string()))); if (number_format->has_currency()) MUST(options->create_data_property_or_throw(vm.names.currency, PrimitiveString::create(vm, number_format->currency()))); if (number_format->has_currency_display()) - MUST(options->create_data_property_or_throw(vm.names.currencyDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->currency_display_string())))); + MUST(options->create_data_property_or_throw(vm.names.currencyDisplay, PrimitiveString::create(vm, number_format->currency_display_string()))); if (number_format->has_currency_sign()) - MUST(options->create_data_property_or_throw(vm.names.currencySign, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->currency_sign_string())))); + MUST(options->create_data_property_or_throw(vm.names.currencySign, PrimitiveString::create(vm, number_format->currency_sign_string()))); if (number_format->has_unit()) MUST(options->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, number_format->unit()))); if (number_format->has_unit_display()) - MUST(options->create_data_property_or_throw(vm.names.unitDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->unit_display_string())))); + MUST(options->create_data_property_or_throw(vm.names.unitDisplay, PrimitiveString::create(vm, number_format->unit_display_string()))); MUST(options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(number_format->min_integer_digits()))); if (number_format->has_min_fraction_digits()) MUST(options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(number_format->min_fraction_digits()))); @@ -173,29 +173,29 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) if (number_format->has_max_significant_digits()) MUST(options->create_data_property_or_throw(vm.names.maximumSignificantDigits, Value(number_format->max_significant_digits()))); MUST(options->create_data_property_or_throw(vm.names.useGrouping, MUST_OR_THROW_OOM(number_format->use_grouping_to_value(vm)))); - MUST(options->create_data_property_or_throw(vm.names.notation, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->notation_string())))); + MUST(options->create_data_property_or_throw(vm.names.notation, PrimitiveString::create(vm, number_format->notation_string()))); if (number_format->has_compact_display()) - MUST(options->create_data_property_or_throw(vm.names.compactDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->compact_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.signDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->sign_display_string())))); - MUST(options->create_data_property_or_throw(vm.names.roundingMode, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->rounding_mode_string())))); + MUST(options->create_data_property_or_throw(vm.names.compactDisplay, PrimitiveString::create(vm, number_format->compact_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.signDisplay, PrimitiveString::create(vm, number_format->sign_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.roundingMode, PrimitiveString::create(vm, number_format->rounding_mode_string()))); MUST(options->create_data_property_or_throw(vm.names.roundingIncrement, Value(number_format->rounding_increment()))); - MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, number_format->trailing_zero_display_string())))); + MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, PrimitiveString::create(vm, number_format->trailing_zero_display_string()))); switch (number_format->rounding_type()) { // 6. If nf.[[RoundingType]] is morePrecision, then case NumberFormatBase::RoundingType::MorePrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "morePrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "morePrecision"sv)))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "morePrecision"_string))); break; // 7. Else if nf.[[RoundingType]] is lessPrecision, then case NumberFormatBase::RoundingType::LessPrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "lessPrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "lessPrecision"sv)))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "lessPrecision"_string))); break; // 8. Else, default: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "auto"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "auto"sv)))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "auto"_string))); break; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp index a98f66a512..c4c30157fb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp @@ -25,7 +25,7 @@ void PluralRulesPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 16.3.2 Intl.PluralRules.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.pluralrules.prototype-tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.PluralRules"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.PluralRules"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.select, select, 1, attr); @@ -45,7 +45,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select) // 4. Return ! ResolvePlural(pr, n).[[PluralCategory]]. auto plurality = MUST_OR_THROW_OOM(resolve_plural(vm, plural_rules, number)); - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality.plural_category))); + return PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality.plural_category)); } // 16.3.4 Intl.PluralRules.prototype.selectRange ( start, end ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.selectrange @@ -72,7 +72,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range) // 6. Return ? ResolvePluralRange(pr, x, y). auto plurality = TRY(resolve_plural_range(vm, plural_rules, x, y)); - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality))); + return PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality)); } // 16.3.5 Intl.PluralRules.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions @@ -93,7 +93,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) // c. If v is not undefined, then // i. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, plural_rules->locale()))); - MUST(options->create_data_property_or_throw(vm.names.type, MUST_OR_THROW_OOM(PrimitiveString::create(vm, plural_rules->type_string())))); + MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, plural_rules->type_string()))); MUST(options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(plural_rules->min_integer_digits()))); if (plural_rules->has_min_fraction_digits()) MUST(options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(plural_rules->min_fraction_digits()))); @@ -103,16 +103,16 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) MUST(options->create_data_property_or_throw(vm.names.minimumSignificantDigits, Value(plural_rules->min_significant_digits()))); if (plural_rules->has_max_significant_digits()) MUST(options->create_data_property_or_throw(vm.names.maximumSignificantDigits, Value(plural_rules->max_significant_digits()))); - MUST(options->create_data_property_or_throw(vm.names.roundingMode, MUST_OR_THROW_OOM(PrimitiveString::create(vm, plural_rules->rounding_mode_string())))); + MUST(options->create_data_property_or_throw(vm.names.roundingMode, PrimitiveString::create(vm, plural_rules->rounding_mode_string()))); MUST(options->create_data_property_or_throw(vm.names.roundingIncrement, Value(plural_rules->rounding_increment()))); - MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, plural_rules->trailing_zero_display_string())))); + MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, PrimitiveString::create(vm, plural_rules->trailing_zero_display_string()))); // 5. Let pluralCategories be a List of Strings containing all possible results of PluralRuleSelect for the selected locale pr.[[Locale]]. auto available_categories = ::Locale::available_plural_categories(plural_rules->locale(), plural_rules->type()); - auto plural_categories = MUST_OR_THROW_OOM(Array::try_create_from<::Locale::PluralCategory>(vm, realm, available_categories, [&](auto category) { + auto plural_categories = Array::create_from<::Locale::PluralCategory>(realm, available_categories, [&](auto category) { return PrimitiveString::create(vm, ::Locale::plural_category_to_string(category)); - })); + }); // 6. Perform ! CreateDataProperty(options, "pluralCategories", CreateArrayFromList(pluralCategories)). MUST(options->create_data_property_or_throw(vm.names.pluralCategories, plural_categories)); @@ -121,17 +121,17 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) // 7. If pr.[[RoundingType]] is morePrecision, then case NumberFormatBase::RoundingType::MorePrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "morePrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "morePrecision"sv)))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "morePrecision"_string))); break; // 8. Else if pr.[[RoundingType]] is lessPrecision, then case NumberFormatBase::RoundingType::LessPrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "lessPrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "lessPrecision"sv)))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "lessPrecision"_string))); break; // 9. Else, default: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "auto"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "auto"sv)))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "auto"_string))); break; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp index c2c84c77cc..e34bdaedd9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp @@ -262,7 +262,7 @@ ThrowCompletionOr format_relative_time_to_parts(VM& vm, RelativeTimeForm 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)))); @@ -270,7 +270,7 @@ ThrowCompletionOr format_relative_time_to_parts(VM& vm, RelativeTimeForm // d. If part.[[Unit]] is not empty, then if (!part.unit.is_empty()) { // i. Perform ! CreateDataPropertyOrThrow(O, "unit", part.[[Unit]]). - MUST(object->create_data_property_or_throw(vm.names.unit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, part.unit)))); + MUST(object->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, part.unit))); } // e. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O). diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp index 893f856011..87ab21e819 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp @@ -23,7 +23,7 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 17.3.2 Intl.RelativeTimeFormat.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype-toStringTag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.RelativeTimeFormat"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.RelativeTimeFormat"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.format, format, 2, attr); @@ -84,8 +84,8 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options) // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, relative_time_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, relative_time_format->style_string())))); - MUST(options->create_data_property_or_throw(vm.names.numeric, MUST_OR_THROW_OOM(PrimitiveString::create(vm, relative_time_format->numeric_string())))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, relative_time_format->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.numeric, PrimitiveString::create(vm, relative_time_format->numeric_string()))); MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, relative_time_format->numbering_system()))); // 5. Return options. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp index 8cea3ea332..fe20bc770d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp @@ -25,7 +25,7 @@ void SegmentIteratorPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 18.6.2.2 %SegmentIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Segmenter String Iterator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Segmenter String Iterator"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.next, next, 0, attr); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp index bc27c7a432..5b2421fe03 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp @@ -24,7 +24,7 @@ void SegmenterPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 18.3.2 Intl.Segmenter.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.segmenter.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Intl.Segmenter"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Segmenter"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); @@ -49,7 +49,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options) // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, segmenter->locale()))); - MUST(options->create_data_property_or_throw(vm.names.granularity, MUST_OR_THROW_OOM(PrimitiveString::create(vm, segmenter->segmenter_granularity_string())))); + MUST(options->create_data_property_or_throw(vm.names.granularity, PrimitiveString::create(vm, segmenter->segmenter_granularity_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/IteratorHelperPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorHelperPrototype.cpp index 4d8f95ee0e..1a40356418 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorHelperPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorHelperPrototype.cpp @@ -25,7 +25,7 @@ void IteratorHelperPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.return_, return_, 0, attr); // 3.1.2.1.3 %IteratorHelperPrototype% [ @@toStringTag ], https://tc39.es/proposal-iterator-helpers/#sec-%iteratorhelperprototype%-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Iterator Helper"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Iterator Helper"_string), Attribute::Configurable); } // 3.1.2.1.1 %IteratorHelperPrototype%.next ( ), https://tc39.es/proposal-iterator-helpers/#sec-%iteratorhelperprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp index 7c689088af..7788489422 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp @@ -27,7 +27,7 @@ void IteratorPrototype::initialize(Realm& realm) Base::initialize(realm); // 3.1.3.13 Iterator.prototype [ @@toStringTag ], https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Iterator"sv)), Attribute::Configurable | Attribute::Writable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Iterator"_string), Attribute::Configurable | Attribute::Writable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.well_known_symbol_iterator(), symbol_iterator, 0, attr); diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 36f2417c7f..52b63ac46f 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -40,7 +40,7 @@ void JSONObject::initialize(Realm& realm) define_native_function(realm, vm.names.parse, parse, 2, attr); // 25.5.3 JSON [ @@toStringTag ], https://tc39.es/ecma262/#sec-json-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "JSON"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "JSON"_string), Attribute::Configurable); } // 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp index 748b96056e..a8fe9607cd 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp @@ -24,7 +24,7 @@ void MapIteratorPrototype::initialize(Realm& realm) Base::initialize(realm); define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Map Iterator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Map Iterator"_string), Attribute::Configurable); } // 24.1.5.2.1 %MapIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%mapiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp index 2a7bbcae8f..d6cb424124 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp @@ -28,7 +28,7 @@ void ModuleNamespaceObject::initialize(Realm& realm) Base::initialize(realm); // 28.3.1 @@toStringTag, https://tc39.es/ecma262/#sec-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Module"sv)), 0); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Module"_string), 0); } // 10.4.6.1 [[GetPrototypeOf]] ( ), https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-getprototypeof diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp index eed94f8191..5a9f62ca1d 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -444,9 +444,9 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string) // 6. Return the String representation of this Number value using the radix specified by radixMV. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in 6.1.6.1.20. if (number_value.is_positive_infinity()) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Infinity"sv)); + return PrimitiveString::create(vm, "Infinity"_string); if (number_value.is_negative_infinity()) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "-Infinity"sv)); + return PrimitiveString::create(vm, "-Infinity"_string); if (number_value.is_nan()) return PrimitiveString::create(vm, "NaN"_string); if (number_value.is_positive_zero() || number_value.is_negative_zero()) diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp index 39daa3f613..144eb7d4a1 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -133,11 +133,11 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string) // 1. If the this value is undefined, return "[object Undefined]". if (this_value.is_undefined()) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "[object Undefined]"sv)); + return PrimitiveString::create(vm, "[object Undefined]"_string); // 2. If the this value is null, return "[object Null]". if (this_value.is_null()) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "[object Null]"sv)); + return PrimitiveString::create(vm, "[object Null]"_string); // 3. Let O be ! ToObject(this value). auto object = MUST(this_value.to_object(vm)); diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp index 15e1c373ca..e733573c8f 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -194,9 +194,9 @@ NonnullGCPtr PrimitiveString::create(VM& vm, FlyString const& s return create(vm, string.to_string()); } -ThrowCompletionOr> PrimitiveString::create(VM& vm, StringView string) +NonnullGCPtr PrimitiveString::create(VM& vm, StringView string) { - return create(vm, TRY_OR_THROW_OOM(vm, String::from_utf8(string))); + return create(vm, String::from_utf8(string).release_value()); } NonnullGCPtr PrimitiveString::create(VM& vm, DeprecatedString string) diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h index 63822aa752..eb75d7ab9f 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h @@ -29,7 +29,7 @@ public: [[nodiscard]] static NonnullGCPtr create(VM&, DeprecatedString); [[nodiscard]] static NonnullGCPtr create(VM&, DeprecatedFlyString const&); [[nodiscard]] static NonnullGCPtr create(VM&, PrimitiveString&, PrimitiveString&); - static ThrowCompletionOr> create(VM&, StringView); + [[nodiscard]] static NonnullGCPtr create(VM&, StringView); virtual ~PrimitiveString(); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 0f53204e75..99499971e2 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -104,7 +104,7 @@ ThrowCompletionOr PromiseAllSettledResolveElementFunction::resolve_elemen auto object = Object::create(realm, realm.intrinsics().object_prototype()); // 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "fulfilled"). - MUST(object->create_data_property_or_throw(vm.names.status, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "fulfilled"sv)))); + MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "fulfilled"_string))); // 11. Perform ! CreateDataPropertyOrThrow(obj, "value", x). MUST(object->create_data_property_or_throw(vm.names.value, vm.argument(0))); @@ -145,7 +145,7 @@ ThrowCompletionOr PromiseAllSettledRejectElementFunction::resolve_element auto object = Object::create(realm, realm.intrinsics().object_prototype()); // 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "rejected"). - MUST(object->create_data_property_or_throw(vm.names.status, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "rejected"sv)))); + MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "rejected"_string))); // 11. Perform ! CreateDataPropertyOrThrow(obj, "reason", x). MUST(object->create_data_property_or_throw(vm.names.reason, vm.argument(0))); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index 7188e29de3..e6d2baaacf 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -868,7 +868,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::source) if (!is(*regexp_object)) { // a. If SameValue(R, %RegExp.prototype%) is true, return "(?:)". if (same_value(regexp_object, realm.intrinsics().regexp_prototype())) - return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "(?:)"sv)); + return PrimitiveString::create(vm, "(?:)"_string); // b. Otherwise, throw a TypeError exception. return vm.throw_completion(ErrorType::NotAnObjectOfType, "RegExp"); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp index 80ddafa28c..48764a8974 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp @@ -26,7 +26,7 @@ void RegExpStringIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, attr); // 22.2.9.2.2 %RegExpStringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "RegExp String Iterator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "RegExp String Iterator"_string), Attribute::Configurable); } // 22.2.9.2.1 %RegExpStringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp index b699cc68c6..4078e0c2fe 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp @@ -26,7 +26,7 @@ void SetIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 24.2.5.2.2 %SetIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%setiteratorprototype%-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Set Iterator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Set Iterator"_string), Attribute::Configurable); } // 24.2.5.2.1 %SetIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%setiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp index 7bd1126999..7b6c8e000f 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp @@ -25,7 +25,7 @@ void StringIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 22.1.5.1.2 %StringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%stringiteratorprototype%-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "String Iterator"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "String Iterator"_string), Attribute::Configurable); } // 22.1.5.1.1 %StringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp index eb29b5c14b..0ad46734ef 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp @@ -20,7 +20,7 @@ void SuppressedErrorPrototype::initialize(Realm& realm) auto& vm = this->vm(); Base::initialize(realm); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.name, MUST(PrimitiveString::create(vm, "SuppressedError"sv)), attr); + define_direct_property(vm.names.name, PrimitiveString::create(vm, "SuppressedError"_string), attr); define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp index 839711c590..c0b0977af5 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp @@ -34,7 +34,7 @@ void SymbolPrototype::initialize(Realm& realm) define_native_function(realm, vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable); // 20.4.3.6 Symbol.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Symbol"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Symbol"_string), Attribute::Configurable); } // thisSymbolValue ( value ), https://tc39.es/ecma262/#thissymbolvalue diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 11f68eadff..719b96b738 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -116,7 +116,7 @@ ThrowCompletionOr get_option(VM& vm, Object const& options, PropertyKey c [](Empty) -> ThrowCompletionOr { return js_undefined(); }, [](bool b) -> ThrowCompletionOr { return Value(b); }, [](double d) -> ThrowCompletionOr { return Value(d); }, - [&vm](StringView s) -> ThrowCompletionOr { return MUST_OR_THROW_OOM(PrimitiveString::create(vm, s)); }); + [&vm](StringView s) -> ThrowCompletionOr { return PrimitiveString::create(vm, s); }); } // 5. If type is "boolean", then @@ -602,7 +602,7 @@ ThrowCompletionOr to_relative_temporal_object(VM& vm, Object const& optio auto date_options = Object::create(realm, nullptr); // g. Perform ! CreateDataPropertyOrThrow(dateOptions, "overflow", "constrain"). - MUST(date_options->create_data_property_or_throw(vm.names.overflow, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "constrain"sv)))); + MUST(date_options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, "constrain"_string))); // h. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, dateOptions). result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, date_options)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index ae00e8db67..3e1289b313 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -120,9 +120,9 @@ ThrowCompletionOr> calendar_fields(VM& vm, Object& calendar, Vect } // 3. Let fieldsArray be ? Call(fields, calendar, « CreateArrayFromList(fieldNames) »). - auto field_names_array = MUST_OR_THROW_OOM(Array::try_create_from(vm, realm, field_names, [&](auto value) { + auto field_names_array = Array::create_from(realm, field_names, [&](auto value) { return PrimitiveString::create(vm, value); - })); + }); auto fields_array = TRY(call(vm, *fields, &calendar, field_names_array)); // 4. Return ? IterableToListOfType(fieldsArray, « String »). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index 4d23a2fcf5..afa5d20469 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -36,7 +36,7 @@ void CalendarPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 12.4.2 Temporal.Calendar.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Calendar"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Calendar"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.id, id_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index c5e8cffad8..bb612bb302 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -692,7 +692,7 @@ ThrowCompletionOr unbalance_duration_relative(VM& vm, double auto until_options = Object::create(realm, nullptr); // iii. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "month"sv)))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"_string))); // iv. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil). auto* until_result = TRY(calendar_date_until(vm, *calendar, relative_to, new_relative_to, *until_options, date_until)); @@ -928,7 +928,7 @@ ThrowCompletionOr balance_duration_relative(VM& vm, double y auto until_options = Object::create(realm, nullptr); // m. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "month"sv)))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"_string))); // n. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil). auto* until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until)); @@ -954,7 +954,7 @@ ThrowCompletionOr balance_duration_relative(VM& vm, double y until_options = Object::create(realm, nullptr); // vi. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "month"sv)))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"_string))); // vii. Set untilResult to ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil). until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until)); @@ -1109,7 +1109,7 @@ ThrowCompletionOr add_duration(VM& vm, double years1, double mon auto difference_options = Object::create(realm, nullptr); // i. Perform ! CreateDataPropertyOrThrow(differenceOptions, "largestUnit", dateLargestUnit). - MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, date_largest_unit)))); + MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, date_largest_unit))); // j. Let dateDifference be ? CalendarDateUntil(calendar, relativeTo, end, differenceOptions). auto* date_difference = TRY(calendar_date_until(vm, calendar, &relative_to, end, *difference_options)); @@ -1312,7 +1312,7 @@ ThrowCompletionOr round_duration(VM& vm, double years, double m auto until_options = Object::create(realm, nullptr); // l. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "year"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "year"sv)))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "year"_string))); // m. Let timePassed be ? CalendarDateUntil(calendar, relativeTo, wholeDaysLater, untilOptions). auto* time_passed = TRY(calendar_date_until(vm, *calendar, relative_to, whole_days_later, *until_options)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp index a716ce5276..2386061580 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp @@ -27,7 +27,7 @@ void DurationPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 7.3.2 Temporal.Duration.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Duration"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Duration"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.years, years_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.months, months_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index c705823d0c..67b7f3be0a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -31,7 +31,7 @@ void InstantPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 8.3.2 Temporal.Instant.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Instant"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Instant"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.epochSeconds, epoch_seconds_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.epochMilliseconds, epoch_milliseconds_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp index 4824c9af79..05a18da5db 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp @@ -33,7 +33,7 @@ void Now::initialize(Realm& realm) auto& vm = this->vm(); // 2.1.1 Temporal.Now [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-now-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Now"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Now"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.timeZone, time_zone, 0, attr); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp index 91a8ba505d..5ee381c6a4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp @@ -32,7 +32,7 @@ void PlainDatePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 3.3.2 Temporal.PlainDate.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainDate"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDate"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index 0187ee7c67..a0fa3efdce 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -33,7 +33,7 @@ void PlainDateTimePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 5.3.2 Temporal.PlainDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainDateTime"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDateTime"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index daf6708b39..5a61ed0bd6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -27,7 +27,7 @@ void PlainMonthDayPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 10.3.2 Temporal.PlainMonthDay.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainMonthDay"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainMonthDay"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.monthCode, month_code_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index 1b89f23a18..124a4064d6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -32,7 +32,7 @@ void PlainTimePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainTime"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainTime"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.hour, hour_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index 50e8b4f539..42c4abb034 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -29,7 +29,7 @@ void PlainYearMonthPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 9.3.2 Temporal.PlainYearMonth.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainYearMonth"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainYearMonth"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp index ddcdb1d58c..54a79d362a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp @@ -33,7 +33,7 @@ void Temporal::initialize(Realm& realm) auto& vm = this->vm(); // 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.Now, MUST(heap().allocate(realm, realm)), attr); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp index 625912d99e..c5747aa7cf 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp @@ -42,7 +42,7 @@ void TimeZonePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toJSON, to_json, 0, attr); // 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.TimeZone"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.TimeZone"_string), Attribute::Configurable); } // 11.4.3 get Temporal.TimeZone.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.timezone.prototype.id diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index 0f17cf40ee..1395032fea 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -33,7 +33,7 @@ void ZonedDateTimePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype-@@tostringtag - define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.ZonedDateTime"sv)), Attribute::Configurable); + define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.ZonedDateTime"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.timeZone, time_zone_getter, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/SyntheticModule.cpp b/Userland/Libraries/LibJS/SyntheticModule.cpp index 038c9229dc..5a1411ff89 100644 --- a/Userland/Libraries/LibJS/SyntheticModule.cpp +++ b/Userland/Libraries/LibJS/SyntheticModule.cpp @@ -151,7 +151,7 @@ ThrowCompletionOr> parse_json_module(StringView source_text auto json_parse = realm.intrinsics().json_parse_function(); // 2. Let json be ? Call(jsonParse, undefined, « sourceText »). - auto json = TRY(call(vm, *json_parse, js_undefined(), MUST_OR_THROW_OOM(PrimitiveString::create(realm.vm(), source_text)))); + auto json = TRY(call(vm, *json_parse, js_undefined(), PrimitiveString::create(realm.vm(), source_text))); // 3. Return CreateDefaultExportSyntheticModule(json, realm, hostDefined). return SyntheticModule::create_default_export_synthetic_module(json, realm, filename); diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp index df16eb225a..729026042a 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -71,11 +71,11 @@ JS::ThrowCompletionOr HeadersIterator::next() switch (m_iteration_kind) { case JS::Object::PropertyKind::Key: - return create_iterator_result_object(vm(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm(), pair_name)), false).ptr(); + return create_iterator_result_object(vm(), JS::PrimitiveString::create(vm(), pair_name), false).ptr(); case JS::Object::PropertyKind::Value: - return create_iterator_result_object(vm(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm(), pair_value)), false).ptr(); + return create_iterator_result_object(vm(), JS::PrimitiveString::create(vm(), pair_value), false).ptr(); case JS::Object::PropertyKind::KeyAndValue: { - auto array = JS::Array::create_from(realm(), { MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm(), pair_name)), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm(), pair_value)) }); + auto array = JS::Array::create_from(realm(), { JS::PrimitiveString::create(vm(), pair_name), JS::PrimitiveString::create(vm(), pair_value) }); return create_iterator_result_object(vm(), array, false).ptr(); } default: diff --git a/Userland/Libraries/LibWeb/Infra/JSON.cpp b/Userland/Libraries/LibWeb/Infra/JSON.cpp index c6b1950440..f962ddc91d 100644 --- a/Userland/Libraries/LibWeb/Infra/JSON.cpp +++ b/Userland/Libraries/LibWeb/Infra/JSON.cpp @@ -20,7 +20,7 @@ WebIDL::ExceptionOr parse_json_string_to_javascript_value(JS::Realm& auto& vm = realm.vm(); // 1. Return ? Call(%JSON.parse%, undefined, « string »). - return TRY(JS::call(vm, *realm.intrinsics().json_parse_function(), JS::js_undefined(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, string)))); + return TRY(JS::call(vm, *realm.intrinsics().json_parse_function(), JS::js_undefined(), JS::PrimitiveString::create(vm, string))); } // https://infra.spec.whatwg.org/#parse-json-bytes-to-a-javascript-value diff --git a/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp b/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp index 19c16f1801..aef12f1b16 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp @@ -72,7 +72,7 @@ WebIDL::ExceptionOr Memory::reset_the_memory_buffer() auto& vm = this->vm(); auto& realm = *vm.current_realm(); - MUST(JS::detach_array_buffer(vm, *m_buffer, MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, "WebAssembly.Memory"sv)))); + MUST(JS::detach_array_buffer(vm, *m_buffer, JS::PrimitiveString::create(vm, "WebAssembly.Memory"_string))); auto buffer = TRY(create_a_memory_buffer(vm, realm, m_address)); m_buffer = buffer; @@ -100,7 +100,7 @@ WebIDL::ExceptionOr> Memory::create_a_memory_b return vm.throw_completion("Could not find the memory instance"sv); auto array_buffer = JS::ArrayBuffer::create(realm, &memory->data()); - array_buffer->set_detach_key(MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, "WebAssembly.Memory"sv))); + array_buffer->set_detach_key(JS::PrimitiveString::create(vm, "WebAssembly.Memory"_string)); return JS::NonnullGCPtr(*array_buffer); }