diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 20:32:51 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 20:33:42 -0400 |
| commit | bfcfaaf5bd5d2586d815ca5c10009975acf3e514 (patch) | |
| tree | c2a3580527c2fae812a9fc2c2af37679d7e4a33f /test/runtime_safety.zig | |
| parent | 15e59eb142af9d4385b9ce5a277df27804e1794e (diff) | |
| download | zig-bfcfaaf5bd5d2586d815ca5c10009975acf3e514.tar.gz zig-bfcfaaf5bd5d2586d815ca5c10009975acf3e514.zip | |
fix codegen for @intCast to u0
Diffstat (limited to 'test/runtime_safety.zig')
| -rw-r--r-- | test/runtime_safety.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index 3d58dfe748..ece6c2283a 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -249,6 +249,19 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\} ); + cases.addRuntimeSafety("value does not fit in shortening cast - u0", + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ @import("std").os.exit(126); + \\} + \\pub fn main() !void { + \\ const x = shorten_cast(1); + \\ if (x == 0) return error.Whatever; + \\} + \\fn shorten_cast(x: u8) u0 { + \\ return @intCast(u0, x); + \\} + ); + cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer", \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { \\ @import("std").os.exit(126); |
