mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:47:46 +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:
parent
01395169dc
commit
236025df19
1 changed files with 3 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/BitCast.h>
|
#include <AK/BitCast.h>
|
||||||
|
#include <AK/Concepts.h>
|
||||||
#include <AK/Format.h>
|
#include <AK/Format.h>
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/Function.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_type(Type::Boolean)
|
||||||
{
|
{
|
||||||
m_value.as_bool = value;
|
m_value.as_bool = value;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue