1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

LibJS: Fix this values in arrow functions

Also added a large this value test (and strict variant) to ensure this
values have no regressions.
This commit is contained in:
davidot 2021-08-09 15:21:15 +02:00 committed by Linus Groh
parent 151447bdf7
commit e1573991a3
4 changed files with 889 additions and 4 deletions

View file

@ -132,6 +132,7 @@ FunctionEnvironment* OrdinaryFunctionObject::create_environment(FunctionObject&
auto* environment = heap().allocate<FunctionEnvironment>(global_object(), m_environment, variables);
environment->set_function_object(function_being_invoked);
if (m_is_arrow_function) {
environment->set_this_binding_status(FunctionEnvironment::ThisBindingStatus::Lexical);
if (is<FunctionEnvironment>(m_environment))
environment->set_new_target(static_cast<FunctionEnvironment*>(m_environment)->new_target());
}