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

LibJS: Prevent implicit pointer-to-bool conversion in Value constructor

For example, say you try to create a Value from an Array and forgot to
include LibJS/Runtime/Array.h. This would cause the boolean constructor
to be used instead of a compile error.
This commit is contained in:
Timothy Flynn 2022-01-27 07:45:00 -05:00 committed by Linus Groh
parent 01395169dc
commit 236025df19

View file

@ -9,6 +9,7 @@
#include <AK/Assertions.h>
#include <AK/BitCast.h>
#include <AK/Concepts.h>
#include <AK/Format.h>
#include <AK/Forward.h>
#include <AK/Function.h>
@ -131,7 +132,8 @@ public:
{
}
explicit Value(bool value)
template<typename T>
requires(SameAs<RemoveCVReference<T>, bool>) explicit Value(T value)
: m_type(Type::Boolean)
{
m_value.as_bool = value;