aboutsummaryrefslogtreecommitdiff
path: root/test/cases/array.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-02-27 00:05:08 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-02-27 00:07:11 -0500
commit1195994880b6a83e61807381df2721ac5256e876 (patch)
tree7ca30412d5c1ad7a3df15633ac3303b74b49eaf6 /test/cases/array.zig
parent25761570f1bb4413020ebbfc959caa3429453517 (diff)
downloadzig-1195994880b6a83e61807381df2721ac5256e876.tar.gz
zig-1195994880b6a83e61807381df2721ac5256e876.zip
fix inability to write to global in some cases
before, when we initialized a variable by copying the initialization value, it made the internal const value references point to a duplicate value, resulting in a phony duplicate global value being updated instead of the real on. now the behavior is as expected. thanks to hoppetosse for pointing out this bug on IRC.
Diffstat (limited to 'test/cases/array.zig')
-rw-r--r--test/cases/array.zig41
1 files changed, 20 insertions, 21 deletions
diff --git a/test/cases/array.zig b/test/cases/array.zig
index 814c360eca..3b91efbc20 100644
--- a/test/cases/array.zig
+++ b/test/cases/array.zig
@@ -72,24 +72,23 @@ fn nestedArrays() {
}
-// TODO
-//var s_array: [8]Sub = undefined;
-//const Sub = struct {
-// b: u8,
-//};
-//const Str = struct {
-// a: []Sub,
-//};
-//fn setGlobalVarArrayViaSliceEmbeddedInStruct() {
-// @setFnTest(this);
-//
-// var s = Str { .a = s_array[0...]};
-//
-// s.a[0].b = 1;
-// s.a[1].b = 2;
-// s.a[2].b = 3;
-//
-// assert(s_array[0].b == 1);
-// assert(s_array[1].b == 2);
-// assert(s_array[2].b == 3);
-//}
+var s_array: [8]Sub = undefined;
+const Sub = struct {
+ b: u8,
+};
+const Str = struct {
+ a: []Sub,
+};
+fn setGlobalVarArrayViaSliceEmbeddedInStruct() {
+ @setFnTest(this);
+
+ var s = Str { .a = s_array[0...]};
+
+ s.a[0].b = 1;
+ s.a[1].b = 2;
+ s.a[2].b = 3;
+
+ assert(s_array[0].b == 1);
+ assert(s_array[1].b == 2);
+ assert(s_array[2].b == 3);
+}