aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-16 17:04:35 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-16 17:04:35 -0400
commit9851a943ed0360433c9612449ed065a6800adc51 (patch)
treedcf15bcb1dd31da8ba975dd2594d7a89f5ca46ae /test/compile_errors.zig
parentf37506391795353bbb87f49b73cf0f82ad9e2c17 (diff)
downloadzig-9851a943ed0360433c9612449ed065a6800adc51.tar.gz
zig-9851a943ed0360433c9612449ed065a6800adc51.zip
add compile error for compile-time integer cast truncating bits
closes #371
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 2ee7954209..1f1f215791 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1827,4 +1827,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\}
,
".tmp_source.zig:4:17: error: division by zero is undefined");
+
+ cases.add("compile-time integer cast truncates bits",
+ \\comptime {
+ \\ const spartan_count: u16 = 300;
+ \\ const byte = u8(spartan_count);
+ \\}
+ ,
+ ".tmp_source.zig:3:20: error: cast from 'u16' to 'u8' truncates bits");
}