diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-05-16 17:04:35 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-05-16 17:04:35 -0400 |
| commit | 9851a943ed0360433c9612449ed065a6800adc51 (patch) | |
| tree | dcf15bcb1dd31da8ba975dd2594d7a89f5ca46ae /test/compile_errors.zig | |
| parent | f37506391795353bbb87f49b73cf0f82ad9e2c17 (diff) | |
| download | zig-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.zig | 8 |
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"); } |
