summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-12-29 15:54:44 +0100
committerLinus Groh <mail@linusgroh.de>2021-12-29 15:54:44 +0100
commit215a56b0e4ae8d720dce08a2ab4ee1c6ec104cc4 (patch)
treecd58ed612b022935f5211825fc3ba68ed8088cdb /Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
parent1817c1f83ca3df98120d1e06d6906d579be8a214 (diff)
downloadserenity-215a56b0e4ae8d720dce08a2ab4ee1c6ec104cc4.zip
LibJS: Convert can_declare_global_var() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
index 769cf84c40..8650edb5de 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
@@ -660,9 +660,12 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
if (global_var_environment) {
if (global_var_environment->has_lexical_declaration(function_name))
return IterationDecision::Continue;
- auto var_definable = global_var_environment->can_declare_global_var(function_name);
- if (vm.exception())
+
+ auto var_definable_or_error = global_var_environment->can_declare_global_var(function_name);
+ if (var_definable_or_error.is_error())
return IterationDecision::Break;
+ auto var_definable = var_definable_or_error.release_value();
+
if (!var_definable)
return IterationDecision::Continue;
}
@@ -697,9 +700,10 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
declaration.for_each_bound_name([&](auto const& name) {
if (!declared_function_names.contains(name)) {
if (global_var_environment) {
- auto variable_definable = global_var_environment->can_declare_global_var(name);
- if (vm.exception())
+ auto variable_definable_or_error = global_var_environment->can_declare_global_var(name);
+ if (variable_definable_or_error.is_error())
return IterationDecision::Break;
+ auto variable_definable = variable_definable_or_error.release_value();
if (!variable_definable) {
vm.throw_exception<TypeError>(global_object, ErrorType::CannotDeclareGlobalVariable, name);
return IterationDecision::Break;