diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-04-12 16:18:41 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-04-12 16:18:41 -0700 |
| commit | 69109bc270c3167a3534dd32fc4f4def855e0be9 (patch) | |
| tree | b9839d8b4f0a5475328e6c1988bdb9ccf5c862ad /test/run_tests.cpp | |
| parent | be4df96e4b80a3307b3661fd5ca3114478499daf (diff) | |
| download | zig-69109bc270c3167a3534dd32fc4f4def855e0be9.tar.gz zig-69109bc270c3167a3534dd32fc4f4def855e0be9.zip | |
add error for dividing by zero in static function evaluation
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index f9f5707bca..5b3d68e72b 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1481,6 +1481,16 @@ fn foo() { const pointer = &array[0]; } )SOURCE", 1, ".tmp_source.zig:4:27: error: out of bounds array access"); + + add_compile_fail_case("compile time division by zero", R"SOURCE( +const x = foo(0); +fn foo(x: i32) -> i32 { + 1 / x +} + )SOURCE", 3, + ".tmp_source.zig:3:1: error: function evaluation caused division by zero", + ".tmp_source.zig:2:14: note: called from here", + ".tmp_source.zig:4:7: note: division by zero here"); } ////////////////////////////////////////////////////////////////////////////// |
