mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
parent
0559cdb554
commit
6cd8004213
12
src/Sema.zig
12
src/Sema.zig
@ -12262,8 +12262,16 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
|
||||
break :p null;
|
||||
};
|
||||
|
||||
const runtime_src = if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| rs: {
|
||||
if (try sema.resolveDefinedValue(block, rhs_src, rhs)) |rhs_val| {
|
||||
const runtime_src = if (switch (lhs_ty.zigTypeTag()) {
|
||||
.Array, .Struct => try sema.resolveMaybeUndefVal(lhs),
|
||||
.Pointer => try sema.resolveDefinedValue(block, lhs_src, lhs),
|
||||
else => unreachable,
|
||||
}) |lhs_val| rs: {
|
||||
if (switch (rhs_ty.zigTypeTag()) {
|
||||
.Array, .Struct => try sema.resolveMaybeUndefVal(rhs),
|
||||
.Pointer => try sema.resolveDefinedValue(block, rhs_src, rhs),
|
||||
else => unreachable,
|
||||
}) |rhs_val| {
|
||||
const lhs_sub_val = if (lhs_ty.isSinglePointer())
|
||||
(try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty)).?
|
||||
else
|
||||
|
||||
@ -45,6 +45,19 @@ fn getArrayLen(a: []const u32) usize {
|
||||
return a.len;
|
||||
}
|
||||
|
||||
test "array concat with undefined" {
|
||||
{
|
||||
var array = "hello".* ++ @as([5]u8, undefined);
|
||||
array[5..10].* = "world".*;
|
||||
try std.testing.expect(std.mem.eql(u8, &array, "helloworld"));
|
||||
}
|
||||
{
|
||||
var array = @as([5]u8, undefined) ++ "world".*;
|
||||
array[0..5].* = "hello".*;
|
||||
try std.testing.expect(std.mem.eql(u8, &array, "helloworld"));
|
||||
}
|
||||
}
|
||||
|
||||
test "array concat with tuple" {
|
||||
const array: [2]u8 = .{ 1, 2 };
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user