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