authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-13 20:49:19-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-16 21:58:53-05:00
log396d57c498278a39d069842321fcdaac90babf02
tree2bcf6a7c368ea49cbe225f6f6fb683cc1b1576e6
parent8f336b397010206d282aec9ce45b47f3b0a5a720
signaturelock-open Commit is signed but in an unrecognized format.

fix failing array test by improving copy_const_val


2 files changed, 11 insertions(+), 1 deletions(-)

src/analyze.cpp+10
......@@ -9318,6 +9318,16 @@ void copy_const_val(ZigValue *dest, ZigValue *src) {
93189318 dest->data.x_struct.fields[i]->parent.data.p_struct.struct_val = dest;
93199319 dest->data.x_struct.fields[i]->parent.data.p_struct.field_index = i;
93209320 }
9321 } else if (dest->type->id == ZigTypeIdArray) {
9322 if (dest->data.x_array.special == ConstArraySpecialNone) {
9323 dest->data.x_array.data.s_none.elements = create_const_vals(dest->type->data.array.len);
9324 for (uint64_t i = 0; i < dest->type->data.array.len; i += 1) {
9325 copy_const_val(&dest->data.x_array.data.s_none.elements[i], &src->data.x_array.data.s_none.elements[i]);
9326 dest->data.x_array.data.s_none.elements[i].parent.id = ConstParentIdArray;
9327 dest->data.x_array.data.s_none.elements[i].parent.data.p_array.array_val = dest;
9328 dest->data.x_array.data.s_none.elements[i].parent.data.p_array.elem_index = i;
9329 }
9330 }
93219331 } else if (type_has_optional_repr(dest->type) && dest->data.x_optional != nullptr) {
93229332 dest->data.x_optional = create_const_vals(1);
93239333 copy_const_val(dest->data.x_optional, src->data.x_optional);
test/stage1/behavior.zig+1-1
......@@ -1,7 +1,7 @@
11comptime {
22 _ = @import("behavior/align.zig");
33 _ = @import("behavior/alignof.zig");
4 //_ = @import("behavior/array.zig");
4 _ = @import("behavior/array.zig");
55 _ = @import("behavior/asm.zig");
66 _ = @import("behavior/async_fn.zig");
77 _ = @import("behavior/atomics.zig");