1// Test that integer types above a certain size will not coerce to a float.
2
3fn testCoerce(Float: type, Int: type) void {
4 var i: Int = 0;
5 _ = &i;
6 _ = @as(Float, i);
7}
8
9export fn entry() void {
10 testCoerce(f16, u11); // Okay
11 testCoerce(f16, u12); // Too big
12
13 testCoerce(f16, i12);
14 testCoerce(f16, i13);
15
16 testCoerce(f32, u24);
17 testCoerce(f32, u25);
18
19 testCoerce(f32, i25);
20 testCoerce(f32, i26);
21
22 testCoerce(f64, u53);
23 testCoerce(f64, u54);
24
25 testCoerce(f64, i54);
26 testCoerce(f64, i55);
27
28 testCoerce(f80, u64);
29 testCoerce(f80, u65);
30
31 testCoerce(f80, i65);
32 testCoerce(f80, i66);
33
34 testCoerce(f128, u113);
35 testCoerce(f128, u114);
36
37 testCoerce(f128, i114);
38 testCoerce(f128, i115);
39}
40
41// error
42//
43// :6:20: error: expected type 'f128', found 'i115'
44// :6:20: error: expected type 'f128', found 'u114'
45// :6:20: error: expected type 'f16', found 'i13'
46// :6:20: error: expected type 'f16', found 'u12'
47// :6:20: error: expected type 'f32', found 'i26'
48// :6:20: error: expected type 'f32', found 'u25'
49// :6:20: error: expected type 'f64', found 'i55'
50// :6:20: error: expected type 'f64', found 'u54'
51// :6:20: error: expected type 'f80', found 'i66'
52// :6:20: error: expected type 'f80', found 'u65'