| 1 | export fn foo() void { |
| 2 | var a: u32 = 2; |
| 3 | _ = &a; |
| 4 | _ = @as(comptime_int, @intCast(a)); |
| 5 | } |
| 6 | export fn bar() void { |
| 7 | var a: u32 = 2; |
| 8 | _ = &a; |
| 9 | _ = @as(u32, @floatFromInt(a)); |
| 10 | } |
| 11 | export fn bar2() void { |
| 12 | _ = @as(comptime_int, @floatFromInt(2)); |
| 13 | } |
| 14 | export fn baz() void { |
| 15 | var a: u32 = 2; |
| 16 | _ = &a; |
| 17 | _ = @as(u32, @intFromFloat(a)); |
| 18 | } |
| 19 | export fn qux() void { |
| 20 | var a: f32 = 2; |
| 21 | _ = &a; |
| 22 | _ = @as(u32, @intCast(a)); |
| 23 | } |
| 24 | |
| 25 | // error |
| 26 | // |
| 27 | // :4:36: error: unable to cast runtime value to 'comptime_int' |
| 28 | // :9:18: error: expected float result type, found 'u32' |
| 29 | // :12:27: error: expected float result type, found 'comptime_int' |
| 30 | // :17:32: error: expected float type, found 'u32' |
| 31 | // :22:27: error: expected integer or vector, found 'f32' |