1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +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> template<typename ValueType>
class [[nodiscard]] ThrowCompletionOr { class [[nodiscard]] ThrowCompletionOr {
public: 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. // Not `explicit` on purpose so that `return vm.throw_completion<Error>(...);` is possible.
ThrowCompletionOr(Completion throw_completion) ThrowCompletionOr(Completion throw_completion)