1// Test that peer type resolution fails for integer types that cannot safely coerce to a float.
2
3fn testAdd(Float: type, Int: type) void {
4 var i: Int = 0;
5 _ = &i;
6 var f: Float = 0;
7 _ = &f;
8 _ = i + f;
9 _ = f + i;
10}
11
12export fn entry() void {
13 testAdd(f16, u11); // Okay
14 testAdd(f16, u12); // Too big
15
16 testAdd(f16, i12);
17 testAdd(f16, i13);
18
19 testAdd(f32, u24);
20 testAdd(f32, u25);
21
22 testAdd(f32, i25);
23 testAdd(f32, i26);
24
25 testAdd(f64, u53);
26 testAdd(f64, u54);
27
28 testAdd(f64, i54);
29 testAdd(f64, i55);
30
31 testAdd(f80, u64);
32 testAdd(f80, u65);
33
34 testAdd(f80, i65);
35 testAdd(f80, i66);
36
37 testAdd(f128, u113);
38 testAdd(f128, u114);
39
40 testAdd(f128, i114);
41 testAdd(f128, i115);
42}
43
44// error
45//
46// :8:11: error: incompatible types: 'i115' and 'f128'
47// :8:9: note: type 'i115' here
48// :8:13: note: type 'f128' here
49// :8:11: error: incompatible types: 'i13' and 'f16'
50// :8:9: note: type 'i13' here
51// :8:13: note: type 'f16' here
52// :8:11: error: incompatible types: 'i26' and 'f32'
53// :8:9: note: type 'i26' here
54// :8:13: note: type 'f32' here
55// :8:11: error: incompatible types: 'i55' and 'f64'
56// :8:9: note: type 'i55' here
57// :8:13: note: type 'f64' here
58// :8:11: error: incompatible types: 'i66' and 'f80'
59// :8:9: note: type 'i66' here
60// :8:13: note: type 'f80' here
61// :8:11: error: incompatible types: 'u114' and 'f128'
62// :8:9: note: type 'u114' here
63// :8:13: note: type 'f128' here
64// :8:11: error: incompatible types: 'u12' and 'f16'
65// :8:9: note: type 'u12' here
66// :8:13: note: type 'f16' here
67// :8:11: error: incompatible types: 'u25' and 'f32'
68// :8:9: note: type 'u25' here
69// :8:13: note: type 'f32' here
70// :8:11: error: incompatible types: 'u54' and 'f64'
71// :8:9: note: type 'u54' here
72// :8:13: note: type 'f64' here
73// :8:11: error: incompatible types: 'u65' and 'f80'
74// :8:9: note: type 'u65' here
75// :8:13: note: type 'f80' here