1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 22:52:07 +00:00

LibJS/Bytecode: Return ThrowCompletionOr<void> from CreateVariable op

This commit is contained in:
Luke Wilde 2023-02-27 22:39:29 +00:00 committed by Linus Groh
parent f4be95af69
commit fb7aaeff3e

View file

@ -449,19 +449,19 @@ ThrowCompletionOr<void> CreateVariable::execute_impl(Bytecode::Interpreter& inte
return vm.throw_completion<InternalError>(TRY_OR_THROW_OOM(vm, String::formatted("Lexical environment already has binding '{}'", name)));
if (m_is_immutable)
vm.lexical_environment()->create_immutable_binding(vm, name, vm.in_strict_mode());
return vm.lexical_environment()->create_immutable_binding(vm, name, vm.in_strict_mode());
else
vm.lexical_environment()->create_mutable_binding(vm, name, vm.in_strict_mode());
return vm.lexical_environment()->create_mutable_binding(vm, name, vm.in_strict_mode());
} else {
if (!m_is_global) {
if (m_is_immutable)
vm.variable_environment()->create_immutable_binding(vm, name, vm.in_strict_mode());
return vm.variable_environment()->create_immutable_binding(vm, name, vm.in_strict_mode());
else
vm.variable_environment()->create_mutable_binding(vm, name, vm.in_strict_mode());
return vm.variable_environment()->create_mutable_binding(vm, name, vm.in_strict_mode());
} else {
// NOTE: CreateVariable with m_is_global set to true is expected to only be used in GlobalDeclarationInstantiation currently, which only uses "false" for "can_be_deleted".
// The only area that sets "can_be_deleted" to true is EvalDeclarationInstantiation, which is currently fully implemented in C++ and not in Bytecode.
verify_cast<GlobalEnvironment>(vm.variable_environment())->create_global_var_binding(name, false);
return verify_cast<GlobalEnvironment>(vm.variable_environment())->create_global_var_binding(name, false);
}
}
return {};