1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibJS: Initialize value in ThrowCompletionOr<void> default constructor

Otherwise, TRY() will crash when calling release_value() on the empty
m_value Optional.
This commit is contained in:
Linus Groh 2021-09-16 14:02:39 +01:00
parent 5f0f0ac413
commit fea27143e9

View file

@ -97,7 +97,10 @@ private:
template<typename ValueType>
class [[nodiscard]] ThrowCompletionOr {
public:
ThrowCompletionOr() requires(IsSame<ValueType, Empty>) = default;
ThrowCompletionOr() requires(IsSame<ValueType, Empty>)
: m_value(Empty {})
{
}
// Not `explicit` on purpose so that `return vm.throw_completion<Error>(...);` is possible.
ThrowCompletionOr(Completion throw_completion)