LibJS: Convert can_declare_global_var() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-12-29 15:54:44 +01:00
commit 215a56b0e4
Notes: sideshowbarker 2024-07-17 21:59:17 +09:00
4 changed files with 15 additions and 10 deletions

View file

@ -3650,9 +3650,10 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
if (declared_function_names.contains(name))
return IterationDecision::Continue;
auto var_definable = global_environment.can_declare_global_var(name);
if (interpreter.exception())
auto var_definable_or_error = global_environment.can_declare_global_var(name);
if (var_definable_or_error.is_error())
return IterationDecision::Break;
auto var_definable = var_definable_or_error.release_value();
if (!var_definable) {
interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::CannotDeclareGlobalVariable, name);