1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

LibJS: Set Error message attributes to writable and configurable only

20.5.1.1 Error ( message )

    When the Error function is called with argument message, the
    following steps are taken:

    [...]
    3b. Let msgDesc be the PropertyDescriptor {
        [[Value]]: msg,
        [[Writable]]: true,
        [[Enumerable]]: false,
        [[Configurable]]: true
    }.
    3c. Perform ! DefinePropertyOrThrow(O, "message", msgDesc).
This commit is contained in:
Linus Groh 2021-06-11 00:22:53 +01:00
parent 0e38c9b2f7
commit f218a4b548

View file

@ -14,8 +14,10 @@ Error* Error::create(GlobalObject& global_object, const String& message)
{
auto& vm = global_object.vm();
auto* error = global_object.heap().allocate<Error>(global_object, *global_object.error_prototype());
if (!message.is_null())
error->define_property(vm.names.message, js_string(vm, message));
if (!message.is_null()) {
u8 attr = Attribute::Writable | Attribute::Configurable;
error->define_property(vm.names.message, js_string(vm, message), attr);
}
return error;
}
@ -29,8 +31,10 @@ Error::Error(Object& prototype)
{ \
auto& vm = global_object.vm(); \
auto* error = global_object.heap().allocate<ClassName>(global_object, *global_object.snake_name##_prototype()); \
if (!message.is_null()) \
error->define_property(vm.names.message, js_string(vm, message)); \
if (!message.is_null()) { \
u8 attr = Attribute::Writable | Attribute::Configurable; \
error->define_property(vm.names.message, js_string(vm, message), attr); \
} \
return error; \
} \
\