| ... | ... | @@ -122,6 +122,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 122 | 122 | \\ var a: u32 = 2; |
| 123 | 123 | \\ _ = @floatToInt(u32, a); |
| 124 | 124 | \\} |
| 125 | \\export fn qux() void { |
| 126 | \\ var a: f32 = 2; |
| 127 | \\ _ = @intCast(u32, a); |
| 128 | \\} |
| 125 | 129 | , &[_][]const u8{ |
| 126 | 130 | "tmp.zig:3:32: error: unable to evaluate constant expression", |
| 127 | 131 | "tmp.zig:3:9: note: referenced here", |
| ... | ... | @@ -129,6 +133,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 129 | 133 | "tmp.zig:7:9: note: referenced here", |
| 130 | 134 | "tmp.zig:11:26: error: expected float type, found 'u32'", |
| 131 | 135 | "tmp.zig:11:9: note: referenced here", |
| 136 | "tmp.zig:15:23: error: expected integer type, found 'f32'", |
| 137 | "tmp.zig:15:9: note: referenced here", |
| 132 | 138 | }); |
| 133 | 139 | |
| 134 | 140 | cases.addTest("invalid float casts", |
| ... | ... | @@ -144,6 +150,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 144 | 150 | \\ var a: f32 = 2; |
| 145 | 151 | \\ _ = @intToFloat(f32, a); |
| 146 | 152 | \\} |
| 153 | \\export fn qux() void { |
| 154 | \\ var a: u32 = 2; |
| 155 | \\ _ = @floatCast(f32, a); |
| 156 | \\} |
| 147 | 157 | , &[_][]const u8{ |
| 148 | 158 | "tmp.zig:3:36: error: unable to evaluate constant expression", |
| 149 | 159 | "tmp.zig:3:9: note: referenced here", |
| ... | ... | @@ -151,6 +161,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 151 | 161 | "tmp.zig:7:9: note: referenced here", |
| 152 | 162 | "tmp.zig:11:26: error: expected int type, found 'f32'", |
| 153 | 163 | "tmp.zig:11:9: note: referenced here", |
| 164 | "tmp.zig:15:25: error: expected float type, found 'u32'", |
| 165 | "tmp.zig:15:9: note: referenced here", |
| 154 | 166 | }); |
| 155 | 167 | |
| 156 | 168 | cases.addTest("invalid assignments", |