summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-02-20 22:16:06 +0000
committerLinus Groh <mail@linusgroh.de>2022-02-20 23:21:40 +0000
commit7feeb2df0d2276e3fb7b4292791623f9f622efaf (patch)
tree36f784e9d8206ed7c6bb1eee1e4a0538422f0ecc /Userland
parent47cdd90836d6e5d218437601f369f6c15476b557 (diff)
downloadserenity-7feeb2df0d2276e3fb7b4292791623f9f622efaf.zip
LibJS: Capture values as handles in Promise.prototype.finally callbacks
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
index ebd1b18d6d..bbda6ff8f7 100644
--- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
@@ -111,9 +111,9 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
auto* promise = TRY(promise_resolve(global_object, constructor, result));
// iii. Let returnValue be a new Abstract Closure with no parameters that captures value and performs the following steps when called:
- auto return_value = [value](auto&, auto&) -> ThrowCompletionOr<Value> {
+ auto return_value = [value_handle = make_handle(value)](auto&, auto&) -> ThrowCompletionOr<Value> {
// 1. Return value.
- return value;
+ return value_handle.value();
};
// iv. Let valueThunk be ! CreateBuiltinFunction(returnValue, 0, "", « »).
@@ -139,9 +139,9 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
auto* promise = TRY(promise_resolve(global_object, constructor, result));
// iii. Let throwReason be a new Abstract Closure with no parameters that captures reason and performs the following steps when called:
- auto throw_reason = [reason](auto&, auto&) -> ThrowCompletionOr<Value> {
+ auto throw_reason = [reason_handle = make_handle(reason)](auto&, auto&) -> ThrowCompletionOr<Value> {
// 1. Return ThrowCompletion(reason).
- return throw_completion(reason);
+ return throw_completion(reason_handle.value());
};
// iv. Let thrower be ! CreateBuiltinFunction(throwReason, 0, "", « »).