aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-10 00:21:27 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-10 00:21:27 -0400
commit63f6676fee83883736af794eaddb4d0ccb890c06 (patch)
treef01f8a01902267451d7c8e57de75157e475f1141 /test/compile_errors.zig
parent623741171629055a22a35bb8278d81a81dcffbde (diff)
downloadzig-63f6676fee83883736af794eaddb4d0ccb890c06.tar.gz
zig-63f6676fee83883736af794eaddb4d0ccb890c06.zip
add compile error for casting negative value to...
...unsigned integer at compile-time
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 6cce0c89bd..b854ada34b 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1801,4 +1801,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\}
,
".tmp_source.zig:2:7: error: remainder division with 'i32' and 'i32': signed integers and floats must use @rem or @mod");
+
+ cases.add("cast negative value to unsigned integer",
+ \\comptime {
+ \\ const value: i32 = -1;
+ \\ const unsigned = u32(value);
+ \\}
+ ,
+ ".tmp_source.zig:3:25: error: attempt to cast negative value to unsigned integer");
}