summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2021-10-13 16:32:06 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-15 10:27:16 +0100
commit1c7c53e5a07b090a32cb726f27fa0d1d7491a0eb (patch)
tree939fb17f066801d5c1f9e2b08c6b41cadf95dfa6 /Userland
parent9394cbcd24ef7f5f139f65ae581d2e528fad5b4d (diff)
downloadserenity-1c7c53e5a07b090a32cb726f27fa0d1d7491a0eb.zip
LibJS: Define length and name in function in correct order
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
index e2acff4bb9..abd92758d4 100644
--- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
@@ -76,6 +76,9 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
{
auto& vm = this->vm();
Base::initialize(global_object);
+ MUST(define_property_or_throw(vm.names.length, { .value = Value(m_function_length), .writable = false, .enumerable = false, .configurable = true }));
+ MUST(define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true }));
+
if (!m_is_arrow_function) {
auto* prototype = vm.heap().allocate<Object>(global_object, *global_object.new_ordinary_function_prototype_object_shape());
switch (m_kind) {
@@ -89,8 +92,6 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
}
define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
}
- MUST(define_property_or_throw(vm.names.length, { .value = Value(m_function_length), .writable = false, .enumerable = false, .configurable = true }));
- MUST(define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true }));
}
ECMAScriptFunctionObject::~ECMAScriptFunctionObject()