stage1: fix concat of sliced str literals
parent
8696e52a3d
commit
d907f574e0
|
@ -826,12 +826,11 @@ static ZigValue *const_ptr_pointee_unchecked_no_isf(CodeGen *g, ZigValue *const_
|
||||||
ZigValue *array_val = const_val->data.x_ptr.data.base_array.array_val;
|
ZigValue *array_val = const_val->data.x_ptr.data.base_array.array_val;
|
||||||
size_t elem_index = const_val->data.x_ptr.data.base_array.elem_index;
|
size_t elem_index = const_val->data.x_ptr.data.base_array.elem_index;
|
||||||
|
|
||||||
// TODO handle sentinel terminated arrays
|
|
||||||
expand_undef_array(g, array_val);
|
expand_undef_array(g, array_val);
|
||||||
result = g->pass1_arena->create<ZigValue>();
|
result = g->pass1_arena->create<ZigValue>();
|
||||||
result->special = array_val->special;
|
result->special = array_val->special;
|
||||||
result->type = get_array_type(g, array_val->type->data.array.child_type,
|
result->type = get_array_type(g, array_val->type->data.array.child_type,
|
||||||
array_val->type->data.array.len - elem_index, nullptr);
|
array_val->type->data.array.len - elem_index, array_val->type->data.array.sentinel);
|
||||||
result->data.x_array.special = ConstArraySpecialNone;
|
result->data.x_array.special = ConstArraySpecialNone;
|
||||||
result->data.x_array.data.s_none.elements = &array_val->data.x_array.data.s_none.elements[elem_index];
|
result->data.x_array.data.s_none.elements = &array_val->data.x_array.data.s_none.elements[elem_index];
|
||||||
result->parent.id = ConstParentIdArray;
|
result->parent.id = ConstParentIdArray;
|
||||||
|
|
|
@ -280,6 +280,11 @@ test "slice syntax resulting in pointer-to-array" {
|
||||||
expect(slice[0] == 5);
|
expect(slice[0] == 5);
|
||||||
comptime expect(@TypeOf(src_slice[0..2]) == *align(4) [2]u8);
|
comptime expect(@TypeOf(src_slice[0..2]) == *align(4) [2]u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn testConcatStrLiterals() void {
|
||||||
|
expectEqualSlices("a"[0..] ++ "b"[0..], "ab");
|
||||||
|
expectEqualSlices("a"[0..:0] ++ "b"[0..:0], "ab");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
S.doTheTest();
|
S.doTheTest();
|
||||||
|
|
Loading…
Reference in New Issue