From 7565b1fda8383b9fcb709d894fa92d37a2ef2e88 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 2 Jan 2022 20:48:38 +0100 Subject: [PATCH] LibJS: Let Completion::update_empty() take an Optional It also needs to be able to take what the spec calls 'empty', which is an Optional in this case (*not* an empty JS::Value). The common use case is updating a completion with another completion, that may also have an empty [[Value]] slot. --- Userland/Libraries/LibJS/Runtime/Completion.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Completion.h b/Userland/Libraries/LibJS/Runtime/Completion.h index 900bc1a8f0..ff3f500d78 100644 --- a/Userland/Libraries/LibJS/Runtime/Completion.h +++ b/Userland/Libraries/LibJS/Runtime/Completion.h @@ -80,7 +80,7 @@ public: } // 6.2.3.4 UpdateEmpty ( completionRecord, value ), https://tc39.es/ecma262/#sec-updateempty - Completion update_empty(Value value) const + Completion update_empty(Optional value) const { // 1. Assert: If completionRecord.[[Type]] is either return or throw, then completionRecord.[[Value]] is not empty. if (m_type == Type::Return || m_type == Type::Throw) @@ -91,7 +91,7 @@ public: return *this; // 3. Return Completion { [[Type]]: completionRecord.[[Type]], [[Value]]: value, [[Target]]: completionRecord.[[Target]] }. - return { m_type, value, m_target }; + return { m_type, move(value), m_target }; } private: