allow unselection/clear of Union/Any

This commit is contained in:
Michael Davidsaver
2020-07-19 21:07:15 -07:00
parent f22715063c
commit 2381f28c73
3 changed files with 19 additions and 2 deletions
+6
View File
@@ -584,12 +584,18 @@ void Value::copyIn(const void *ptr, StoreType type)
break;
}
case StoreType::Compound:
if(type==StoreType::Null) {
store->as<Value>() = Value(); // unselect Union or Any
break;
}
if(desc->code==TypeCode::Any) {
// assigning variant union.
auto& val = store->as<Value>();
if(type==StoreType::Compound) {
val = *reinterpret_cast<const Value*>(ptr);
break;
} else {
val = Value::Helper::build(ptr, type);
break;