Browse Source

Keep Variant type after zero()

kobewi 1 year ago
parent
commit
275e9d7028
1 changed files with 6 additions and 0 deletions
  1. 6 0
      core/variant/variant.cpp

+ 6 - 0
core/variant/variant.cpp

@@ -1291,7 +1291,13 @@ void Variant::zero() {
 			break;
 			break;
 
 
 		default:
 		default:
+			Type prev_type = type;
 			this->clear();
 			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;
 			break;
 	}
 	}
 }
 }