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

LibJS: Convert set_mutable_binding() to ThrowCompletionOr

Also add spec step comments to it while we're here.
This commit is contained in:
Linus Groh 2021-10-09 19:34:54 +01:00
parent ae397541fb
commit 7652138ce0
11 changed files with 68 additions and 52 deletions

View file

@ -166,9 +166,10 @@ Value FunctionDeclaration::execute(Interpreter& interpreter, GlobalObject& globa
if (m_is_hoisted) {
// Perform special annexB steps see step 3 of: https://tc39.es/ecma262/#sec-web-compat-functiondeclarationinstantiation
auto function_object = interpreter.vm().running_execution_context().lexical_environment->get_binding_value(global_object, name(), false);
interpreter.vm().running_execution_context().variable_environment->set_mutable_binding(global_object, name(), function_object, false);
VERIFY(!interpreter.exception());
auto* variable_environment = interpreter.vm().running_execution_context().variable_environment;
auto* lexical_environment = interpreter.vm().running_execution_context().lexical_environment;
auto function_object = lexical_environment->get_binding_value(global_object, name(), false);
MUST(variable_environment->set_mutable_binding(global_object, name(), function_object, false));
}
return {};