From b3f9cb1f01205a0bc2911a2abe496a25bd85edd1 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 9 Sep 2020 11:57:58 +0200 Subject: [PATCH] Work around a bug in the V8 headers (#463) --- src/support.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/support.h b/src/support.h index b89c0ff2..884204ca 100644 --- a/src/support.h +++ b/src/support.h @@ -11,6 +11,26 @@ #include "v8/include/v8.h" +// Work around a bug in the V8 headers. +// +// The following template is defined in v8-internal.h. It has a subtle bug that +// indirectly makes it impossible to convert `v8::Data` handles to themselves. +// Some methods do that impliclity so they don't compile without this hack; one +// example is `Local MaybeLocal::FromMaybe(Local default_value)`. +// +// Spot the bug :) +// +// ``` +// template +// V8_INLINE void PerformCastCheck(T* data) { +// CastCheck::value && +// !std::is_same>::value>::Perform(data); +// } +// ``` +template <> +template <> +inline void v8::internal::CastCheck::Perform(v8::Data* data) {} + // Check assumptions made in binding code. static_assert(sizeof(bool) == sizeof(uint8_t), ""); static_assert(sizeof(std::unique_ptr) == sizeof(void*), "");