aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-01-16 15:24:03 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-01-16 15:24:03 -0500
commitfdbc2d8da1c707859af8f8bb42a27ae9d3a62159 (patch)
tree1a1289cac097941e6bef0757a1c7e0fdf3c1668c /test/run_tests.cpp
parent98faf4f74984db615ba62de285308dfc5092ec7c (diff)
downloadzig-fdbc2d8da1c707859af8f8bb42a27ae9d3a62159.tar.gz
zig-fdbc2d8da1c707859af8f8bb42a27ae9d3a62159.zip
implement error when assigning to field of const struct
closes #48
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 7ecc1ca36c..bd551d9294 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1595,6 +1595,16 @@ const zero: i32 = 0;
const a = zero{1};
)SOURCE", 1, ".tmp_source.zig:3:11: error: expected type, found 'i32'");
+ add_compile_fail_case("assign to constant field", R"SOURCE(
+const Foo = struct {
+ field: i32,
+};
+fn derp() {
+ const f = Foo {.field = 1234,};
+ f.field = 0;
+}
+ )SOURCE", 1, ".tmp_source.zig:7:13: error: cannot assign to constant");
+
}
//////////////////////////////////////////////////////////////////////////////