1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

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().
This commit is contained in:
davidot 2021-12-30 16:38:28 +01:00 committed by Linus Groh
parent 7608af13cd
commit b303b8cf4e

View file

@ -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) {