mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
parent
799a558e39
commit
35afa3fd8b
@ -4380,7 +4380,7 @@ fn zirValidateArrayInit(
|
||||
var block_index = block.instructions.items.len - 1;
|
||||
while (block.instructions.items[block_index] != elem_ptr_air_inst) {
|
||||
if (block_index == 0) {
|
||||
array_is_comptime = true;
|
||||
array_is_comptime = false;
|
||||
continue :outer;
|
||||
}
|
||||
block_index -= 1;
|
||||
|
@ -574,3 +574,25 @@ test "tuple to array handles sentinel" {
|
||||
};
|
||||
try expect(S.b[0] == 1);
|
||||
}
|
||||
|
||||
test "array init of container level array variable" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
|
||||
const S = struct {
|
||||
var pair: [2]usize = .{ 1, 2 };
|
||||
noinline fn foo(x: usize, y: usize) void {
|
||||
pair = [2]usize{ x, y };
|
||||
}
|
||||
noinline fn bar(x: usize, y: usize) void {
|
||||
var tmp: [2]usize = .{ x, y };
|
||||
pair = tmp;
|
||||
}
|
||||
};
|
||||
try expectEqual([2]usize{ 1, 2 }, S.pair);
|
||||
S.foo(3, 4);
|
||||
try expectEqual([2]usize{ 3, 4 }, S.pair);
|
||||
S.bar(5, 6);
|
||||
try expectEqual([2]usize{ 5, 6 }, S.pair);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user