authorgravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2020-06-20 18:35:01+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-06-21 14:57:12-04:00
logd907f574e02aadf8196e616bcc2fb2813cf2c82c
treeafd234afad685c9498582e90329cda004fb6e6a8
parent8696e52a3d617ce30ec6202adc89cb10c67bcc43

stage1: fix concat of sliced str literals


2 files changed, 6 insertions(+), 2 deletions(-)

src/ir.cpp+1-2
...@@ -826,12 +826,11 @@ static ZigValue *const_ptr_pointee_unchecked_no_isf(CodeGen *g, ZigValue *const_...@@ -826,12 +826,11 @@ static ZigValue *const_ptr_pointee_unchecked_no_isf(CodeGen *g, ZigValue *const_
826 ZigValue *array_val = const_val->data.x_ptr.data.base_array.array_val;826 ZigValue *array_val = const_val->data.x_ptr.data.base_array.array_val;
827 size_t elem_index = const_val->data.x_ptr.data.base_array.elem_index;827 size_t elem_index = const_val->data.x_ptr.data.base_array.elem_index;
828828
829 // TODO handle sentinel terminated arrays
830 expand_undef_array(g, array_val);829 expand_undef_array(g, array_val);
831 result = g->pass1_arena->create<ZigValue>();830 result = g->pass1_arena->create<ZigValue>();
832 result->special = array_val->special;831 result->special = array_val->special;
833 result->type = get_array_type(g, array_val->type->data.array.child_type,832 result->type = get_array_type(g, array_val->type->data.array.child_type,
834 array_val->type->data.array.len - elem_index, nullptr);833 array_val->type->data.array.len - elem_index, array_val->type->data.array.sentinel);
835 result->data.x_array.special = ConstArraySpecialNone;834 result->data.x_array.special = ConstArraySpecialNone;
836 result->data.x_array.data.s_none.elements = &array_val->data.x_array.data.s_none.elements[elem_index];835 result->data.x_array.data.s_none.elements = &array_val->data.x_array.data.s_none.elements[elem_index];
837 result->parent.id = ConstParentIdArray;836 result->parent.id = ConstParentIdArray;
test/stage1/behavior/slice.zig+5
...@@ -280,6 +280,11 @@ test "slice syntax resulting in pointer-to-array" {...@@ -280,6 +280,11 @@ test "slice syntax resulting in pointer-to-array" {
280 expect(slice[0] == 5);280 expect(slice[0] == 5);
281 comptime expect(@TypeOf(src_slice[0..2]) == *align(4) [2]u8);281 comptime expect(@TypeOf(src_slice[0..2]) == *align(4) [2]u8);
282 }282 }
283
284 fn testConcatStrLiterals() void {
285 expectEqualSlices("a"[0..] ++ "b"[0..], "ab");
286 expectEqualSlices("a"[0..:0] ++ "b"[0..:0], "ab");
287 }
283 };288 };
284289
285 S.doTheTest();290 S.doTheTest();