From 396d57c498278a39d069842321fcdaac90babf02 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 13 Jan 2020 20:49:19 -0500 Subject: [PATCH] fix failing array test by improving copy_const_val --- src/analyze.cpp | 10 ++++++++++ test/stage1/behavior.zig | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/analyze.cpp b/src/analyze.cpp index 94d0c66e196dbc28c2d416c178713ed0265ddc94..4b3b024b538351d98ff50cb730317796dd7a945c 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -9318,6 +9318,16 @@ void copy_const_val(ZigValue *dest, ZigValue *src) { dest->data.x_struct.fields[i]->parent.data.p_struct.struct_val = dest; dest->data.x_struct.fields[i]->parent.data.p_struct.field_index = i; } + } else if (dest->type->id == ZigTypeIdArray) { + if (dest->data.x_array.special == ConstArraySpecialNone) { + dest->data.x_array.data.s_none.elements = create_const_vals(dest->type->data.array.len); + for (uint64_t i = 0; i < dest->type->data.array.len; i += 1) { + copy_const_val(&dest->data.x_array.data.s_none.elements[i], &src->data.x_array.data.s_none.elements[i]); + dest->data.x_array.data.s_none.elements[i].parent.id = ConstParentIdArray; + dest->data.x_array.data.s_none.elements[i].parent.data.p_array.array_val = dest; + dest->data.x_array.data.s_none.elements[i].parent.data.p_array.elem_index = i; + } + } } else if (type_has_optional_repr(dest->type) && dest->data.x_optional != nullptr) { dest->data.x_optional = create_const_vals(1); copy_const_val(dest->data.x_optional, src->data.x_optional); diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig index f9bd9deef4f8ef592d6a357727f7f514af5dc0db..ea8720d98ca62d78e12acdfc3ff45353b5e24c15 100644 --- a/test/stage1/behavior.zig +++ b/test/stage1/behavior.zig @@ -1,7 +1,7 @@ comptime { _ = @import("behavior/align.zig"); _ = @import("behavior/alignof.zig"); - //_ = @import("behavior/array.zig"); + _ = @import("behavior/array.zig"); _ = @import("behavior/asm.zig"); _ = @import("behavior/async_fn.zig"); _ = @import("behavior/atomics.zig"); -- 2.54.0