From 275e9d7028bc2e0d4f6c9a74d91ededce0631b40 Mon Sep 17 00:00:00 2001 From: kobewi Date: Wed, 8 Nov 2023 00:01:21 +0100 Subject: [PATCH] Keep Variant type after zero() --- core/variant/variant.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 09fb34e7c141..4c0212075b0d 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1291,7 +1291,13 @@ void Variant::zero() { break; default: + Type prev_type = type; this->clear(); + if (type != prev_type) { + // clear() changes type to NIL, so it needs to be restored. + Callable::CallError ce; + Variant::construct(prev_type, *this, nullptr, 0, ce); + } break; } }