diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-05 18:01:48 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-05 18:01:48 -0400 |
| commit | b517bea734c0141fcda6b267a8f0de34cddc65f8 (patch) | |
| tree | 64c287ecaa26f47b05f06fee0b234c9c18ab0eb9 /test/compile_errors.zig | |
| parent | 768d1fc539e425280acba5b30256e3b1267ddfbb (diff) | |
| download | zig-b517bea734c0141fcda6b267a8f0de34cddc65f8.tar.gz zig-b517bea734c0141fcda6b267a8f0de34cddc65f8.zip | |
allow comptime_int to @floatToInt
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index ce67f25ed7..00fc33d122 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,33 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add( + "non int passed to @intToFloat", + \\export fn entry() void { + \\ const x = @intToFloat(f32, 1.1); + \\} + , + ".tmp_source.zig:2:32: error: expected int type, found 'comptime_float'", + ); + + cases.add( + "non float passed to @floatToInt", + \\export fn entry() void { + \\ const x = @floatToInt(i32, i32(54)); + \\} + , + ".tmp_source.zig:2:35: error: expected float type, found 'i32'", + ); + + cases.add( + "out of range comptime_int passed to @floatToInt", + \\export fn entry() void { + \\ const x = @floatToInt(i8, 200); + \\} + , + ".tmp_source.zig:2:31: error: integer value 200 cannot be implicitly casted to type 'i8'", + ); + + cases.add( "load too many bytes from comptime reinterpreted pointer", \\export fn entry() void { \\ const float: f32 = 5.99999999999994648725e-01; @@ -487,24 +514,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { ); cases.add( - "non int passed to @intToFloat", - \\export fn entry() void { - \\ const x = @intToFloat(f32, 1.1); - \\} - , - ".tmp_source.zig:2:32: error: expected int type, found 'comptime_float'", - ); - - cases.add( - "non float passed to @floatToInt", - \\export fn entry() void { - \\ const x = @floatToInt(i32, 54); - \\} - , - ".tmp_source.zig:2:32: error: expected float type, found 'comptime_int'", - ); - - cases.add( "use implicit casts to assign null to non-nullable pointer", \\export fn entry() void { \\ var x: i32 = 1234; |
