summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2021-12-30 16:38:28 +0100
committerLinus Groh <mail@linusgroh.de>2021-12-30 20:14:13 +0100
commitb303b8cf4e03835ca542172333b4575b6f142fc3 (patch)
treed195e77b4bc140cf7b46a8a29d129cb1a70be31c /Userland
parent7608af13cd61e615e643d08f6ce27cd0ae74028f (diff)
downloadserenity-b303b8cf4e03835ca542172333b4575b6f142fc3.zip
LibJS: Convert thrown exception to completion in binding initialization
This regressed in 676554d3 as it assumed to_reference() (already) returned a completion type instead of putting the error in vm.exception().
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp
index 8aebd2fab9..67ab562598 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.cpp
+++ b/Userland/Libraries/LibJS/Runtime/VM.cpp
@@ -303,7 +303,10 @@ ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const
},
[&](NonnullRefPtr<BindingPattern> const&) -> ThrowCompletionOr<Optional<Reference>> { return Optional<Reference> {}; },
[&](NonnullRefPtr<MemberExpression> const& member_expression) -> ThrowCompletionOr<Optional<Reference>> {
- return member_expression->to_reference(interpreter(), global_object);
+ auto reference = member_expression->to_reference(interpreter(), global_object);
+ if (auto* thrown_exception = exception())
+ return JS::throw_completion(thrown_exception->value());
+ return reference;
}));
if (auto* thrown_exception = exception())
@@ -350,7 +353,10 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const
},
[&](NonnullRefPtr<BindingPattern> const&) -> ThrowCompletionOr<Optional<Reference>> { return Optional<Reference> {}; },
[&](NonnullRefPtr<MemberExpression> const& member_expression) -> ThrowCompletionOr<Optional<Reference>> {
- return member_expression->to_reference(interpreter(), global_object);
+ auto reference = member_expression->to_reference(interpreter(), global_object);
+ if (auto* thrown_exception = exception())
+ return JS::throw_completion(thrown_exception->value());
+ return reference;
}));
if (entry.is_rest) {