about summary refs log tree commit diff
path: root/lang/zig/namespaced-global.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lang/zig/namespaced-global.zig')
-rw-r--r--lang/zig/namespaced-global.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/lang/zig/namespaced-global.zig b/lang/zig/namespaced-global.zig
new file mode 100644
index 0000000..2d06ced
--- /dev/null
+++ b/lang/zig/namespaced-global.zig
@@ -0,0 +1,15 @@
+const std = @import("std");
+const expect = std.testing.expect;
+
+test "namespaced global variable" {
+    expect(foo() == 1235);
+    expect(foo() == 1236);
+}
+
+fn foo() i32 {
+    const S = struct {
+        var x: i32 = 1234;
+    };
+    S.x += 1;
+    return S.x;
+}