aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2015-12-24 13:47:07 -0700
committerAndrew Kelley <superjoe30@gmail.com>2015-12-24 13:47:07 -0700
commit08a7ce7dd5f348b37bf98c5040ad58720a7818b5 (patch)
treedeb58ea9bc24f131a81e18784b5904947cac2df6 /test/run_tests.cpp
parent8915883cf627c12a7e6da9bb813d456407ebb091 (diff)
downloadzig-08a7ce7dd5f348b37bf98c5040ad58720a7818b5.tar.gz
zig-08a7ce7dd5f348b37bf98c5040ad58720a7818b5.zip
add error for missing or duplicate field in struct value expr
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index f5f814de8b..f6a3c3dfec 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -877,6 +877,36 @@ struct A { y : i32, }
struct A { x : i32, }
export fn f(a : A) {}
)SOURCE", 1, ".tmp_source.zig:3:13: error: byvalue struct parameters not yet supported on exported functions");
+
+ add_compile_fail_case("duplicate field in struct value expression", R"SOURCE(
+struct A {
+ x : i32,
+ y : i32,
+ z : i32,
+}
+fn f() {
+ const a = A {
+ .z = 1,
+ .y = 2,
+ .x = 3,
+ .z = 4,
+ };
+}
+ )SOURCE", 1, ".tmp_source.zig:12:9: error: duplicate field");
+
+ add_compile_fail_case("missing field in struct value expression", R"SOURCE(
+struct A {
+ x : i32,
+ y : i32,
+ z : i32,
+}
+fn f() {
+ const a = A {
+ .z = 4,
+ .y = 2,
+ };
+}
+ )SOURCE", 1, ".tmp_source.zig:8:15: error: missing field: 'x'");
}
static void print_compiler_invocation(TestCase *test_case) {