Copy union const values correctly
parent
2c7fc1c5c5
commit
129a4fb251
|
@ -9597,6 +9597,12 @@ void copy_const_val(CodeGen *g, ZigValue *dest, ZigValue *src) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (dest->type->id == ZigTypeIdUnion) {
|
||||||
|
bigint_init_bigint(&dest->data.x_union.tag, &src->data.x_union.tag);
|
||||||
|
dest->data.x_union.payload = g->pass1_arena->create<ZigValue>();
|
||||||
|
copy_const_val(g, dest->data.x_union.payload, src->data.x_union.payload);
|
||||||
|
dest->data.x_union.payload->parent.id = ConstParentIdUnion;
|
||||||
|
dest->data.x_union.payload->parent.data.p_union.union_val = dest;
|
||||||
} else if (type_has_optional_repr(dest->type) && dest->data.x_optional != nullptr) {
|
} else if (type_has_optional_repr(dest->type) && dest->data.x_optional != nullptr) {
|
||||||
dest->data.x_optional = g->pass1_arena->create<ZigValue>();
|
dest->data.x_optional = g->pass1_arena->create<ZigValue>();
|
||||||
copy_const_val(g, dest->data.x_optional, src->data.x_optional);
|
copy_const_val(g, dest->data.x_optional, src->data.x_optional);
|
||||||
|
|
|
@ -402,3 +402,11 @@ test "type info for async frames" {
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "type info: value is correctly copied" {
|
||||||
|
comptime {
|
||||||
|
var ptrInfo = @typeInfo([]u32);
|
||||||
|
ptrInfo.Pointer.size = .One;
|
||||||
|
expect(@typeInfo([]u32).Pointer.size == .Slice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue