diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-06-06 00:43:03 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-05 23:54:08 +0100 |
commit | 2a8f4f097c30fd15f8d421aa062dcab3f63cc13f (patch) | |
tree | 8bd56b53b4ad6e05e867bd017fb270331c323185 /Userland/Libraries/LibJS/Runtime/Object.cpp | |
parent | 31534055e4e2ab17d3db6cb761e528568cd6e5f9 (diff) | |
download | serenity-2a8f4f097c30fd15f8d421aa062dcab3f63cc13f.zip |
LibJS: Throw TypeError on write to non-writable property in strict mode
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Object.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Object.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index c7fa05b863..4667eed1d2 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -637,6 +637,8 @@ bool Object::put_own_property(const StringOrSymbol& property_name, Value value, auto value_here = m_storage[metadata.value().offset]; if (!new_property && mode == PutOwnPropertyMode::Put && !value_here.is_accessor() && !metadata.value().attributes.is_writable()) { dbgln_if(OBJECT_DEBUG, "Disallow write to non-writable property"); + if (throw_exceptions && vm().in_strict_mode()) + vm().throw_exception<TypeError>(global_object(), ErrorType::DescWriteNonWritable, property_name.to_display_string()); return false; } |