LibJS: Ensure Optional<Completion>'s defaults to empty completion
Default-constructing the m_value Completion made it have an undefined JS value when not overridden in a constructor, such as the conditional initialization in Optional(Optional<JS::Completion> const&). See investigation by Tim here: https://github.com/SerenityOS/serenity/pull/16498#discussion_r1049090456 Co-authored-by: Timothy Flynn <trflynn89@pm.me>
This commit is contained in:
parent
0991464de6
commit
029db614e3
Notes:
sideshowbarker
2024-07-17 03:09:38 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/029db614e3 Pull-request: https://github.com/SerenityOS/serenity/pull/16498 Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 2 additions and 5 deletions
|
@ -131,10 +131,7 @@ class Optional<JS::Completion> {
|
|||
public:
|
||||
using ValueType = JS::Completion;
|
||||
|
||||
Optional()
|
||||
: m_value(JS::Completion(JS::Completion::EmptyTag {}))
|
||||
{
|
||||
}
|
||||
Optional() = default;
|
||||
|
||||
Optional(Optional<JS::Completion> const& other)
|
||||
{
|
||||
|
@ -228,7 +225,7 @@ public:
|
|||
JS::Completion* operator->() { return &value(); }
|
||||
|
||||
private:
|
||||
JS::Completion m_value;
|
||||
JS::Completion m_value { JS::Completion::EmptyTag {} };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue