Browse Source

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.
Timothy Flynn 2 years ago
parent
commit
2b5054c903
1 changed files with 6 additions and 0 deletions
  1. 6 0
      Userland/Libraries/LibJS/Runtime/Completion.h

+ 6 - 0
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<Completion> m_throw_completion;
     Optional<ValueType> m_value;