浏览代码

Keep Variant type after zero()

kobewi 1 年之前
父节点
当前提交
275e9d7028
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      core/variant/variant.cpp

+ 6 - 0
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;
 	}
 }