aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-04-10 13:18:42 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-04-10 13:18:42 -0700
commitb117b5907c50f495c53770bfc351e0431e6474b3 (patch)
tree38565c201e7dd562fc10db66f9f15b56d424a2d1 /test/run_tests.cpp
parent0683bd8bf66c00d38f79d49319b5d80ac1f9a470 (diff)
downloadzig-b117b5907c50f495c53770bfc351e0431e6474b3.tar.gz
zig-b117b5907c50f495c53770bfc351e0431e6474b3.zip
add error for accessing empty array
closes #134
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 266720ccbd..3316c792cb 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1814,6 +1814,13 @@ fn derp(){}
add_compile_fail_case("assign null to non-nullable pointer", R"SOURCE(
const a: &u8 = null;
)SOURCE", 1, ".tmp_source.zig:2:16: error: expected maybe type, got '&u8'");
+
+ add_compile_fail_case("indexing an array of size zero", R"SOURCE(
+const array = []u8{};
+fn foo() {
+ const pointer = &array[0];
+}
+ )SOURCE", 1, ".tmp_source.zig:4:27: error: out of bounds array access");
}
//////////////////////////////////////////////////////////////////////////////