From 236025df193a4841ea0984eaaca8b88b1ea1bb55 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 27 Jan 2022 07:45:00 -0500 Subject: [PATCH] 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. --- Userland/Libraries/LibJS/Runtime/Value.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 52e7dd2c43..8bd6ecf412 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -131,7 +132,8 @@ public: { } - explicit Value(bool value) + template + requires(SameAs, bool>) explicit Value(T value) : m_type(Type::Boolean) { m_value.as_bool = value;