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