aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig
blob: d6bf372a88ce5554f3da12d2768bc132cde3555c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export fn foo() void {
    var a: f32 = 2;
    _ = &a;
    _ = @as(comptime_int, @intFromFloat(a));
}
export fn bar() void {
    var a: u32 = 2;
    _ = &a;
    _ = @as(comptime_float, @floatFromInt(a));
}

// error
// backend=stage2
// target=native
//
// :4:41: error: unable to resolve comptime value
// :4:41: note: value being casted to 'comptime_int' must be comptime-known
// :9:43: error: unable to resolve comptime value
// :9:43: note: value being casted to 'comptime_float' must be comptime-known