authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-19 18:10:13-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-19 21:18:27-07:00
logec4cd87ed76b47eae9fce95f18ec396aa44f2c0f
tree595034129e5dc7fa389c5d6dc8aeef6736d0bc75
parente778e4714006a78814dc09c66713073ab2f05515

add test coverage for fixed bug. closes #5518


1 files changed, 14 insertions(+), 0 deletions(-)

test/behavior/basic.zig+14
...@@ -1143,3 +1143,17 @@ test "orelse coercion as function argument" {...@@ -1143,3 +1143,17 @@ test "orelse coercion as function argument" {
1143 var foo = Container.init(optional orelse .{});1143 var foo = Container.init(optional orelse .{});
1144 try expect(foo.a.?.start == -1);1144 try expect(foo.a.?.start == -1);
1145}1145}
1146
1147test "runtime-known globals initialized with undefined" {
1148 const S = struct {
1149 var array: [10]u32 = [_]u32{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
1150 var vp: [*]u32 = undefined;
1151 var s: []u32 = undefined;
1152 };
1153
1154 S.vp = &S.array;
1155 S.s = S.vp[0..5];
1156
1157 try expect(S.s[0] == 1);
1158 try expect(S.s[4] == 5);
1159}