diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-01-27 07:45:00 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-27 16:27:00 +0000 |
commit | 236025df193a4841ea0984eaaca8b88b1ea1bb55 (patch) | |
tree | 027296f01e87043bfdd8cce855223d7e4d1d5d95 /Userland/Libraries | |
parent | 01395169dcc1e7c566aff4d374070af1163235f3 (diff) | |
download | serenity-236025df193a4841ea0984eaaca8b88b1ea1bb55.zip |
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.h | 4 |
1 files changed, 3 insertions, 1 deletions
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 <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; |