aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-14 13:07:45 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-14 13:07:45 -0400
commita7570186ebdffd97878a983b8e8a09902841e279 (patch)
tree68ad4b544efe41eda086a8af5682ee383d5efbb7 /test/compile_errors.zig
parent63f6676fee83883736af794eaddb4d0ccb890c06 (diff)
downloadzig-a7570186ebdffd97878a983b8e8a09902841e279.tar.gz
zig-a7570186ebdffd97878a983b8e8a09902841e279.zip
add compile error for comptime division by zero
closes #372
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index b854ada34b..2ee7954209 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1809,4 +1809,22 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\}
,
".tmp_source.zig:3:25: error: attempt to cast negative value to unsigned integer");
+
+ cases.add("compile-time division by zero",
+ \\comptime {
+ \\ const a: i32 = 1;
+ \\ const b: i32 = 0;
+ \\ const c = a / b;
+ \\}
+ ,
+ ".tmp_source.zig:4:17: error: division by zero is undefined");
+
+ cases.add("compile-time remainder division by zero",
+ \\comptime {
+ \\ const a: i32 = 1;
+ \\ const b: i32 = 0;
+ \\ const c = a % b;
+ \\}
+ ,
+ ".tmp_source.zig:4:17: error: division by zero is undefined");
}