From b303b8cf4e03835ca542172333b4575b6f142fc3 Mon Sep 17 00:00:00 2001 From: davidot Date: Thu, 30 Dec 2021 16:38:28 +0100 Subject: 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(). --- Userland/Libraries/LibJS/Runtime/VM.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Userland') 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 VM::property_binding_initialization(BindingPattern const }, [&](NonnullRefPtr const&) -> ThrowCompletionOr> { return Optional {}; }, [&](NonnullRefPtr const& member_expression) -> ThrowCompletionOr> { - 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 VM::iterator_binding_initialization(BindingPattern const }, [&](NonnullRefPtr const&) -> ThrowCompletionOr> { return Optional {}; }, [&](NonnullRefPtr const& member_expression) -> ThrowCompletionOr> { - 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) { -- cgit v1.2.3