mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibJS: Convert create_global_var_binding() to ThrowCompletionOr
This commit is contained in:
parent
8296d3fbd2
commit
4767be1459
4 changed files with 14 additions and 28 deletions
|
@ -3688,8 +3688,8 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
|
|||
}
|
||||
|
||||
if (!declared_function_names.contains(function_name) && !declared_var_names.contains(function_name)) {
|
||||
global_environment.create_global_var_binding(function_name, false);
|
||||
if (interpreter.exception())
|
||||
auto result = global_environment.create_global_var_binding(function_name, false);
|
||||
if (result.is_error())
|
||||
return IterationDecision::Break;
|
||||
declared_function_names.set(function_name);
|
||||
}
|
||||
|
@ -3730,11 +3730,8 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
|
|||
return throw_completion(exception->value());
|
||||
}
|
||||
|
||||
for (auto& var_name : declared_var_names) {
|
||||
global_environment.create_global_var_binding(var_name, false);
|
||||
if (auto* exception = interpreter.exception())
|
||||
return throw_completion(exception->value());
|
||||
}
|
||||
for (auto& var_name : declared_var_names)
|
||||
TRY(global_environment.create_global_var_binding(var_name, false));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue