From 2b5054c9037dae39d38f5832013eeecd2bcc8394 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 28 Jan 2023 12:45:22 -0500 Subject: [PATCH] LibJS: Add a method to ThrowCompletionOr to drop allocation errors This should solely be used to ignore completions from Heap::allocate in currently-infallible contexts. It's mostly meant to let us both ignore these errors and mark them with a FIXME in one go. --- Userland/Libraries/LibJS/Runtime/Completion.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/Completion.h b/Userland/Libraries/LibJS/Runtime/Completion.h index 96dbd62a3a..6c0e51c346 100644 --- a/Userland/Libraries/LibJS/Runtime/Completion.h +++ b/Userland/Libraries/LibJS/Runtime/Completion.h @@ -332,6 +332,12 @@ public: [[nodiscard]] ValueType release_value() { return m_value.release_value(); } Completion release_error() { return m_throw_completion.release_value(); } + ValueType release_allocated_value_but_fixme_should_propagate_errors() + { + VERIFY(!is_error()); + return release_value(); + } + private: Optional m_throw_completion; Optional m_value;