diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp index 16e6b03ca0..f5d2a46802 100644 --- a/Userland/Libraries/LibJS/Console.cpp +++ b/Userland/Libraries/LibJS/Console.cpp @@ -622,7 +622,7 @@ ThrowCompletionOr> ConsoleClient::formatter(MarkedVector AggregateErrorPrototype::initialize(Realm& realm) MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.name, PrimitiveString::create(vm, "AggregateError"), attr); - define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); + define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); return {}; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 5fddd36339..f3ae154081 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -993,7 +993,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join) // FWIW: engine262, a "100% spec compliant" ECMA-262 impl, aborts with "too much recursion". // Same applies to Array.prototype.toLocaleString(). if (s_array_join_seen_objects.contains(this_object)) - return PrimitiveString::create(vm, ""); + return PrimitiveString::create(vm, String {}); s_array_join_seen_objects.set(this_object); ArmedScopeGuard unsee_object_guard = [&] { s_array_join_seen_objects.remove(this_object); @@ -1704,7 +1704,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string) auto* this_object = TRY(vm.this_value().to_object(vm)); if (s_array_join_seen_objects.contains(this_object)) - return PrimitiveString::create(vm, ""); + return PrimitiveString::create(vm, String {}); s_array_join_seen_objects.set(this_object); ArmedScopeGuard unsee_object_guard = [&] { s_array_join_seen_objects.remove(this_object); diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 203da27ccf..13d8690016 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -25,7 +25,7 @@ ThrowCompletionOr ErrorPrototype::initialize(Realm& realm) MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.name, PrimitiveString::create(vm, "Error"), attr); - define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), 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" // Every other engine seems to have this in some way or another, and the spec @@ -124,21 +124,21 @@ 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()) \ - { \ - } \ - \ - ThrowCompletionOr PrototypeName::initialize(Realm& realm) \ - { \ - auto& vm = this->vm(); \ - MUST_OR_THROW_OOM(Base::initialize(realm)); \ - u8 attr = Attribute::Writable | Attribute::Configurable; \ - define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName), attr); \ - define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); \ - \ - return {}; \ +#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ + PrototypeName::PrototypeName(Realm& realm) \ + : PrototypeObject(*realm.intrinsics().error_prototype()) \ + { \ + } \ + \ + ThrowCompletionOr PrototypeName::initialize(Realm& realm) \ + { \ + auto& vm = this->vm(); \ + MUST_OR_THROW_OOM(Base::initialize(realm)); \ + u8 attr = Attribute::Writable | Attribute::Configurable; \ + define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName), attr); \ + define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); \ + \ + return {}; \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 79b68489a2..c9fcdd6f4a 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -36,7 +36,7 @@ ThrowCompletionOr FunctionPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toString, to_string, 0, attr); define_native_function(realm, *vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); - define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), Attribute::Configurable); + define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable); return {}; } diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp index 8e3c456749..aa88e07431 100644 --- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -232,7 +232,7 @@ void Intrinsics::initialize_intrinsics(Realm& realm) }, 0, "", &realm); m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0); - m_throw_type_error_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), 0); + m_throw_type_error_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), 0); MUST(m_throw_type_error_function->internal_prevent_extensions()); initialize_constructor(vm, vm.names.Error, *m_error_constructor, m_error_prototype); diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 5391e1c552..87bc647a9a 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -59,7 +59,7 @@ ThrowCompletionOr> StringConstructor::construct(FunctionObj PrimitiveString* primitive_string; if (!vm.argument_count()) - primitive_string = PrimitiveString::create(vm, ""); + primitive_string = PrimitiveString::create(vm, String {}); else primitive_string = TRY(vm.argument(0).to_primitive_string(vm)); auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype)); @@ -75,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw) auto literal_segments = TRY(length_of_array_like(vm, *raw)); if (literal_segments == 0) - return PrimitiveString::create(vm, ""); + return PrimitiveString::create(vm, String {}); auto const number_of_substituions = vm.argument_count() - 1; diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp index c0b3cc6234..1d660d29f2 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp @@ -21,7 +21,7 @@ ThrowCompletionOr SuppressedErrorPrototype::initialize(Realm& realm) MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.name, PrimitiveString::create(vm, "SuppressedError"), attr); - define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); + define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); return {}; } diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index e577e23a6d..4182badfed 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -129,7 +129,7 @@ WebIDL::ExceptionOr XMLHttpRequest::response() if (m_response_type == Bindings::XMLHttpRequestResponseType::Empty || m_response_type == Bindings::XMLHttpRequestResponseType::Text) { // 1. If this’s state is not loading or done, then return the empty string. if (m_state != State::Loading && m_state != State::Done) - return JS::PrimitiveString::create(vm, ""); + return JS::PrimitiveString::create(vm, String {}); // 2. Return the result of getting a text response for this. return JS::PrimitiveString::create(vm, get_text_response());