]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
luawrapper: We also need to decay the type while reading it back
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 9 Dec 2025 08:34:56 +0000 (09:34 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 9 Dec 2025 09:06:17 +0000 (10:06 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
ext/luawrapper/include/LuaContext.hpp

index 7a333dd44469fab4a1ac6e27f12b3d517d2261c2..97530a52efaf9e4e906d6fd5f17e0a7bfa14934e 100644 (file)
@@ -3039,8 +3039,12 @@ private:
         if constexpr (I >= nbTypes) {
             return boost::none;
         }
-        if (const auto val = Reader<std::variant_alternative_t<I, ReturnType>>::read(state, index)) {
-            return ReturnType{*val};
+        using InitialType = std::variant_alternative_t<I, ReturnType>;
+        using DecayedType = std::decay_t<InitialType>;
+        if (const auto val = Reader<DecayedType>::read(state, index)) {
+            // we are using the initial, non-decayed type so that a
+            // cv-qualifiers are not ignored
+            return ReturnType{std::in_place_type<InitialType>, *val};
         }
         if constexpr (I < (nbTypes - 1)) {
             return variantRead<I + 1>(state, index);