diff options
author | Linus Groh <mail@linusgroh.de> | 2021-04-12 00:08:28 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-12 09:38:57 +0200 |
commit | da177c6517ab0ba77facfe4ff5a078562f887e96 (patch) | |
tree | 33123a6ad6e98f09b4390796dc20f26458c0800e /Userland/Libraries/LibJS/Runtime/VM.h | |
parent | 6e9eb0a284661803d634ce0bd8c1656a156878bb (diff) | |
download | serenity-da177c6517ab0ba77facfe4ff5a078562f887e96.zip |
LibJS: Make Errors fully spec compliant
The previous handling of the name and message properties specifically
was breaking websites that created their own error types and relied on
the error prototype working correctly - not assuming an JS::Error this
object, that is.
The way it works now, and it is supposed to work, is:
- Error.prototype.name and Error.prototype.message just have initial
string values and are no longer getters/setters
- When constructing an error with a message, we create a regular
property on the newly created object, so a lookup of the message
property will either get it from the object directly or go though the
prototype chain
- Internal m_name/m_message properties are no longer needed and removed
This makes printing errors slightly more complicated, as we can no
longer rely on the (safe) internal properties, and cannot trust a
property lookup either - get_without_side_effects() is used to solve
this, it's not perfect but something we can revisit later.
I did some refactoring along the way, there was some really old stuff in
there - accessing vm.call_frame().arguments[0] is not something we (have
to) do anymore :^)
Fixes #6245.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/VM.h')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/VM.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 1988e20afa..702ec9580a 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -124,7 +124,7 @@ public: // Ensure we got some stack space left, so the next function call doesn't kill us. // This value is merely a guess and might need tweaking at a later point. if (m_stack_info.size_free() < 16 * KiB) - throw_exception<Error>(global_object, "RuntimeError", "Call stack size limit exceeded"); + throw_exception<Error>(global_object, "Call stack size limit exceeded"); else m_call_stack.append(&call_frame); } |