aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2015-12-22 13:45:13 -0700
committerAndrew Kelley <superjoe30@gmail.com>2015-12-22 13:45:13 -0700
commitebd7aeb5411c8dba35d6898524928d7ee905c06b (patch)
tree7375cc34f8e02c8a68c75ad77218f543c265ebf0 /test
parentfe3ad27d5f909fbe1e4d6f863dcf5f69b7dc6507 (diff)
downloadzig-ebd7aeb5411c8dba35d6898524928d7ee905c06b.tar.gz
zig-ebd7aeb5411c8dba35d6898524928d7ee905c06b.zip
add test for invalid struct field access
Diffstat (limited to 'test')
-rw-r--r--test/run_tests.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 53efe09ae2..35fedabc87 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -838,6 +838,17 @@ struct A { b : B, }
struct B { c : C, }
struct C { a : A, }
)SOURCE", 1, ".tmp_source.zig:2:1: error: struct has infinite size");
+
+ add_compile_fail_case("invalid struct field", R"SOURCE(
+struct A { x : i32, }
+fn f() {
+ var a : A;
+ a.foo = 1;
+ const y = a.bar;
+}
+ )SOURCE", 2,
+ ".tmp_source.zig:5:6: error: no member named 'foo' in 'A'",
+ ".tmp_source.zig:6:16: error: no member named 'bar' in 'A'");
}
static void print_compiler_invocation(TestCase *test_case) {