summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-12-29 15:50:50 +0100
committerLinus Groh <mail@linusgroh.de>2021-12-29 15:50:50 +0100
commit1817c1f83ca3df98120d1e06d6906d579be8a214 (patch)
tree47b0305b9deb22c722d893cbde833d1d503c027b /Userland
parent9571631b58e1257dfa547243eb1a985401ee4fce (diff)
downloadserenity-1817c1f83ca3df98120d1e06d6906d579be8a214.zip
LibJS: Convert has_restricted_global_property() to ThrowCompletionOr
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/AST.cpp5
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h2
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);