aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behavior/basic.zig')
-rw-r--r--test/behavior/basic.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig
index f3d511916f..08d29fdb30 100644
--- a/test/behavior/basic.zig
+++ b/test/behavior/basic.zig
@@ -459,3 +459,18 @@ var gdt = [_]GDTEntry{
GDTEntry{ .field = 2 },
};
var global_ptr = &gdt[0];
+
+test "global constant is loaded with a runtime-known index" {
+ const S = struct {
+ fn doTheTest() !void {
+ var index: usize = 1;
+ const ptr = &pieces[index].field;
+ try expect(ptr.* == 2);
+ }
+ const Piece = struct {
+ field: i32,
+ };
+ const pieces = [_]Piece{ Piece{ .field = 1 }, Piece{ .field = 2 }, Piece{ .field = 3 } };
+ };
+ try S.doTheTest();
+}