diff options
-rw-r--r-- | Userland/Libraries/LibJS/AST.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 00e4bf7d20..d72ec95e73 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -3593,9 +3593,10 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i return IterationDecision::Break; } - auto restricted_global = global_environment.has_restricted_global_property(name); - if (interpreter.exception()) + auto restricted_global_or_error = global_environment.has_restricted_global_property(name); + if (restricted_global_or_error.is_error()) return IterationDecision::Break; + auto restricted_global = restricted_global_or_error.release_value(); if (restricted_global) interpreter.vm().throw_exception<SyntaxError>(global_object, ErrorType::RestrictedGlobalProperty, name); diff --git a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp index 14ea1c88a3..709e90a345 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp @@ -175,14 +175,14 @@ bool GlobalEnvironment::has_lexical_declaration(FlyString const& name) const } // 9.1.1.4.14 HasRestrictedGlobalProperty ( N ), https://tc39.es/ecma262/#sec-hasrestrictedglobalproperty -bool GlobalEnvironment::has_restricted_global_property(FlyString const& name) const +ThrowCompletionOr<bool> GlobalEnvironment::has_restricted_global_property(FlyString const& name) const { // 1. Let ObjRec be envRec.[[ObjectRecord]]. // 2. Let globalObject be ObjRec.[[BindingObject]]. auto& global_object = m_object_record->binding_object(); // 3. Let existingProp be ? globalObject.[[GetOwnProperty]](N). - auto existing_prop = TRY_OR_DISCARD(global_object.internal_get_own_property(name)); + auto existing_prop = TRY(global_object.internal_get_own_property(name)); // 4. If existingProp is undefined, return false. if (!existing_prop.has_value()) diff --git a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h index 8379fb326c..1abe82948f 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h @@ -33,7 +33,7 @@ public: bool has_var_declaration(FlyString const& name) const; bool has_lexical_declaration(FlyString const& name) const; - bool has_restricted_global_property(FlyString const& name) const; + ThrowCompletionOr<bool> has_restricted_global_property(FlyString const& name) const; bool can_declare_global_var(FlyString const& name) const; bool can_declare_global_function(FlyString const& name) const; void create_global_var_binding(FlyString const& name, bool can_be_deleted); |