mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-29 03:06:10 +08:00
Fixes: https://codeberg.org/ziglang/zig/issues/32147 Co-authored-by: rue04 <rue04@rue04.de> Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35663 Reviewed-by: mlugg <mlugg@mlugg.co.uk>
28 lines
629 B
Zig
28 lines
629 B
Zig
export fn foo() void {
|
|
var a: f32 = 2;
|
|
_ = &a;
|
|
_ = @as(comptime_float, @floatCast(a));
|
|
}
|
|
export fn bar() void {
|
|
var a: f32 = 2;
|
|
_ = &a;
|
|
_ = @as(f32, @intFromFloat(a));
|
|
}
|
|
export fn baz() void {
|
|
var a: f32 = 2;
|
|
_ = &a;
|
|
_ = @as(f32, @floatFromInt(a));
|
|
}
|
|
export fn qux() void {
|
|
var a: u32 = 2;
|
|
_ = &a;
|
|
_ = @as(f32, @floatCast(a));
|
|
}
|
|
|
|
// error
|
|
//
|
|
// :4:40: error: unable to cast runtime value to 'comptime_float'
|
|
// :9:18: error: expected integer result type, found 'f32'
|
|
// :14:32: error: expected integer type, found 'f32'
|
|
// :19:29: error: expected float or vector type, found 'u32'
|