Skip to content

Commit 1cf5928

Browse files
Clean up analysis tests for peer type resolution
1 parent 9a858fe commit 1cf5928

File tree

1 file changed

+78
-121
lines changed

1 file changed

+78
-121
lines changed

tests/analysis/peer_type_resolution.zig

Lines changed: 78 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -7,173 +7,130 @@ const s: S = .{
77
.float = 1.2,
88
};
99

10-
pub fn main() !void {
11-
var runtime_bool: bool = true;
10+
var runtime_bool: bool = true;
1211

13-
const widened_int_0 = if (runtime_bool) @as(i8, 0) else @as(i16, 0);
14-
_ = widened_int_0;
15-
// ^^^^^^^^^^^^^ (i16)()
12+
const widened_int_0 = if (runtime_bool) @as(i8, 0) else @as(i16, 0);
13+
// ^^^^^^^^^^^^^ (i16)()
1614

17-
const widened_int_1 = if (runtime_bool) @as(i16, 0) else @as(i8, 0);
18-
_ = widened_int_1;
19-
// ^^^^^^^^^^^^^ (i16)()
15+
const widened_int_1 = if (runtime_bool) @as(i16, 0) else @as(i8, 0);
16+
// ^^^^^^^^^^^^^ (i16)()
2017

21-
const optional_0 = if (runtime_bool) s else @as(?S, s);
22-
_ = optional_0;
23-
// ^^^^^^^^^^ (?S)()
18+
const optional_0 = if (runtime_bool) s else @as(?S, s);
19+
// ^^^^^^^^^^ (?S)()
2420

25-
const optional_1 = if (runtime_bool) @as(?S, s) else s;
26-
_ = optional_1;
27-
// ^^^^^^^^^^ (?S)()
21+
const optional_1 = if (runtime_bool) @as(?S, s) else s;
22+
// ^^^^^^^^^^ (?S)()
2823

29-
const optional_2 = if (runtime_bool) null else s;
30-
_ = optional_2;
31-
// ^^^^^^^^^^ (?S)()
24+
const optional_2 = if (runtime_bool) null else s;
25+
// ^^^^^^^^^^ (?S)()
3226

33-
const optional_3 = if (runtime_bool) s else null;
34-
_ = optional_3;
35-
// ^^^^^^^^^^ (?S)()
27+
const optional_3 = if (runtime_bool) s else null;
28+
// ^^^^^^^^^^ (?S)()
3629

37-
const optional_4 = if (runtime_bool) null else @as(?S, s);
38-
_ = optional_4;
39-
// ^^^^^^^^^^ (?S)()
30+
const optional_4 = if (runtime_bool) null else @as(?S, s);
31+
// ^^^^^^^^^^ (?S)()
4032

41-
const optional_5 = if (runtime_bool) @as(?S, s) else null;
42-
_ = optional_5;
43-
// ^^^^^^^^^^ (?S)()
33+
const optional_5 = if (runtime_bool) @as(?S, s) else null;
34+
// ^^^^^^^^^^ (?S)()
4435

45-
const error_set_0 = if (runtime_bool) error.A else @as(error{ A, B }, error.A);
46-
_ = error_set_0 catch {};
47-
// ^^^^^^^^^^^ (error{A,B})()
36+
const error_set_0 = if (runtime_bool) error.A else @as(error{ A, B }, error.A);
37+
// ^^^^^^^^^^^ (error{A,B})()
4838

49-
const error_set_1 = if (runtime_bool) @as(error{ A, B }, error.A) else error.A;
50-
_ = error_set_1 catch {};
51-
// ^^^^^^^^^^^ (error{A,B})()
39+
const error_set_1 = if (runtime_bool) @as(error{ A, B }, error.A) else error.A;
40+
// ^^^^^^^^^^^ (error{A,B})()
5241

53-
const error_set_2 = if (runtime_bool) error.B else error.A;
54-
_ = error_set_2 catch {};
55-
// ^^^^^^^^^^^ (error{B,A})()
42+
const error_set_2 = if (runtime_bool) error.B else error.A;
43+
// ^^^^^^^^^^^ (error{B,A})()
5644

57-
const error_set_3 = if (runtime_bool) error.A else error.B;
58-
_ = error_set_3 catch {};
59-
// ^^^^^^^^^^^ (error{A,B})()
45+
const error_set_3 = if (runtime_bool) error.A else error.B;
46+
// ^^^^^^^^^^^ (error{A,B})()
6047

61-
const error_set_4 = if (runtime_bool) @as(error{ B, C }, error.B) else @as(error{ A, B }, error.A);
62-
_ = error_set_4 catch {};
63-
// ^^^^^^^^^^^ (error{B,C,A})()
48+
const error_set_4 = if (runtime_bool) @as(error{ B, C }, error.B) else @as(error{ A, B }, error.A);
49+
// ^^^^^^^^^^^ (error{B,C,A})()
6450

65-
const error_set_5 = if (runtime_bool) @as(error{ A, B }, error.A) else @as(error{ B, C }, error.B);
66-
_ = error_set_5 catch {};
67-
// ^^^^^^^^^^^ (error{A,B,C})()
51+
const error_set_5 = if (runtime_bool) @as(error{ A, B }, error.A) else @as(error{ B, C }, error.B);
52+
// ^^^^^^^^^^^ (error{A,B,C})()
6853

69-
const error_union_0 = if (runtime_bool) s else @as(error{A}!S, s);
70-
_ = error_union_0 catch {};
71-
// ^^^^^^^^^^^^^ (error{A}!S)()
54+
const error_union_0 = if (runtime_bool) s else @as(error{A}!S, s);
55+
// ^^^^^^^^^^^^^ (error{A}!S)()
7256

73-
const error_union_1 = if (runtime_bool) @as(error{A}!S, s) else s;
74-
_ = error_union_1 catch {};
75-
// ^^^^^^^^^^^^^ (error{A}!S)()
57+
const error_union_1 = if (runtime_bool) @as(error{A}!S, s) else s;
58+
// ^^^^^^^^^^^^^ (error{A}!S)()
7659

77-
const error_union_2 = if (runtime_bool) @as(?S, s) else @as(error{A}!S, s);
78-
_ = error_union_2 catch {};
79-
// ^^^^^^^^^^^^^ (error{A}!?S)()
60+
const error_union_2 = if (runtime_bool) @as(?S, s) else @as(error{A}!S, s);
61+
// ^^^^^^^^^^^^^ (error{A}!?S)()
8062

81-
const error_union_3 = if (runtime_bool) @as(error{A}!S, s) else @as(?S, s);
82-
_ = error_union_3 catch {};
83-
// ^^^^^^^^^^^^^ (error{A}!?S)()
63+
const error_union_3 = if (runtime_bool) @as(error{A}!S, s) else @as(?S, s);
64+
// ^^^^^^^^^^^^^ (error{A}!?S)()
8465

85-
const error_union_4 = if (runtime_bool) null else @as(error{A}!S, s);
86-
_ = error_union_4 catch {};
87-
// ^^^^^^^^^^^^^ (error{A}!?S)()
66+
const error_union_4 = if (runtime_bool) null else @as(error{A}!S, s);
67+
// ^^^^^^^^^^^^^ (error{A}!?S)()
8868

89-
const error_union_5 = if (runtime_bool) @as(error{A}!S, s) else null;
90-
_ = error_union_5 catch {};
91-
// ^^^^^^^^^^^^^ (error{A}!?S)()
69+
const error_union_5 = if (runtime_bool) @as(error{A}!S, s) else null;
70+
// ^^^^^^^^^^^^^ (error{A}!?S)()
9271

93-
const error_union_6 = if (runtime_bool) @as(error{B}!S, s) else @as(error{A}!S, s);
94-
_ = error_union_6 catch {};
95-
// ^^^^^^^^^^^^^ (error{B,A}!S)()
72+
const error_union_6 = if (runtime_bool) @as(error{B}!S, s) else @as(error{A}!S, s);
73+
// ^^^^^^^^^^^^^ (error{B,A}!S)()
9674

97-
const error_union_7 = if (runtime_bool) @as(error{A}!S, s) else @as(error{B}!S, s);
98-
_ = error_union_7 catch {};
99-
// ^^^^^^^^^^^^^ (error{A,B}!S)()
75+
const error_union_7 = if (runtime_bool) @as(error{A}!S, s) else @as(error{B}!S, s);
76+
// ^^^^^^^^^^^^^ (error{A,B}!S)()
10077

101-
const error_union_8 = if (runtime_bool) @as(error{A}!?S, s) else @as(error{A}!S, s);
102-
_ = error_union_8 catch {};
103-
// ^^^^^^^^^^^^^ (error{A}!?S)()
78+
const error_union_8 = if (runtime_bool) @as(error{A}!?S, s) else @as(error{A}!S, s);
79+
// ^^^^^^^^^^^^^ (error{A}!?S)()
10480

105-
const error_union_9 = if (runtime_bool) @as(error{A}!S, s) else @as(error{A}!?S, s);
106-
_ = error_union_9 catch {};
107-
// ^^^^^^^^^^^^^ (error{A}!?S)()
81+
const error_union_9 = if (runtime_bool) @as(error{A}!S, s) else @as(error{A}!?S, s);
82+
// ^^^^^^^^^^^^^ (error{A}!?S)()
10883

109-
const error_union_10 = if (runtime_bool) @as(error{B}!?S, s) else @as(error{A}!S, s);
110-
_ = error_union_10 catch {};
111-
// ^^^^^^^^^^^^^^ (error{B,A}!?S)()
84+
const error_union_10 = if (runtime_bool) @as(error{B}!?S, s) else @as(error{A}!S, s);
85+
// ^^^^^^^^^^^^^^ (error{B,A}!?S)()
11286

113-
const error_union_11 = if (runtime_bool) @as(error{A}!S, s) else @as(error{B}!?S, s);
114-
_ = error_union_11 catch {};
115-
// ^^^^^^^^^^^^^^ (error{A,B}!?S)()
87+
const error_union_11 = if (runtime_bool) @as(error{A}!S, s) else @as(error{B}!?S, s);
88+
// ^^^^^^^^^^^^^^ (error{A,B}!?S)()
11689

117-
const error_union_12 = if (runtime_bool) @as(error{B}!error{A}!S, s) else @as(error{A}!?S, s);
118-
_ = try try error_union_12;
119-
// ^^^^^^^^^^^^^^ (error{B,A}!error{A}!?S)()
90+
const error_union_12 = if (runtime_bool) @as(error{B}!error{A}!S, s) else @as(error{A}!?S, s);
91+
// ^^^^^^^^^^^^^^ (error{B,A}!error{A}!?S)()
12092

121-
const error_union_13 = if (runtime_bool) @as(error{A}!?S, s) else @as(error{B}!error{A}!S, s);
122-
_ = try try error_union_13;
123-
// ^^^^^^^^^^^^^^ (error{A,B}!error{A}!?S)()
93+
const error_union_13 = if (runtime_bool) @as(error{A}!?S, s) else @as(error{B}!error{A}!S, s);
94+
// ^^^^^^^^^^^^^^ (error{A,B}!error{A}!?S)()
12495

125-
const error_union_14 = if (runtime_bool) @as(error{B}!error{A}!S, s) else @as(error{A}!error{B}!?S, s);
126-
_ = try try error_union_14;
127-
// ^^^^^^^^^^^^^^ (error{B,A}!error{A,B}!?S)()
96+
const error_union_14 = if (runtime_bool) @as(error{B}!error{A}!S, s) else @as(error{A}!error{B}!?S, s);
97+
// ^^^^^^^^^^^^^^ (error{B,A}!error{A,B}!?S)()
12898

129-
const error_union_15 = if (runtime_bool) @as(error{A}!error{B}!?S, s) else @as(error{B}!error{A}!S, s);
130-
_ = try try error_union_15;
131-
// ^^^^^^^^^^^^^^ (error{A,B}!error{B,A}!?S)()
99+
const error_union_15 = if (runtime_bool) @as(error{A}!error{B}!?S, s) else @as(error{B}!error{A}!S, s);
100+
// ^^^^^^^^^^^^^^ (error{A,B}!error{B,A}!?S)()
132101

133-
const error_union_16 = if (runtime_bool) error.A else s;
134-
_ = error_union_16;
135-
// ^^^^^^^^^^^^^^ (error{A}!S)()
102+
const error_union_16 = if (runtime_bool) error.A else s;
103+
// ^^^^^^^^^^^^^^ (error{A}!S)()
136104

137-
const error_union_17 = if (runtime_bool) s else error.A;
138-
_ = error_union_17;
139-
// ^^^^^^^^^^^^^^ (error{A}!S)()
105+
const error_union_17 = if (runtime_bool) s else error.A;
106+
// ^^^^^^^^^^^^^^ (error{A}!S)()
140107

141-
const error_union_18 = if (runtime_bool) error.A else @as(i32, 0);
142-
_ = error_union_18;
143-
// ^^^^^^^^^^^^^^ (error{A}!i32)()
108+
const error_union_18 = if (runtime_bool) error.A else @as(i32, 0);
109+
// ^^^^^^^^^^^^^^ (error{A}!i32)()
144110

145-
const error_union_19 = if (runtime_bool) @as(i32, 0) else error.A;
146-
_ = error_union_19;
147-
// ^^^^^^^^^^^^^^ (error{A}!i32)()
111+
const error_union_19 = if (runtime_bool) @as(i32, 0) else error.A;
112+
// ^^^^^^^^^^^^^^ (error{A}!i32)()
148113

149-
const error_union_20 = if (runtime_bool) error.A else @as(error{B}!S, s);
150-
_ = error_union_20;
151-
// ^^^^^^^^^^^^^^ (error{A,B}!S)()
114+
const error_union_20 = if (runtime_bool) error.A else @as(error{B}!S, s);
115+
// ^^^^^^^^^^^^^^ (error{A,B}!S)()
152116

153-
const error_union_21 = if (runtime_bool) @as(error{B}!S, s) else error.A;
154-
_ = error_union_21;
155-
// ^^^^^^^^^^^^^^ (error{A,B}!S)()
117+
const error_union_21 = if (runtime_bool) @as(error{B}!S, s) else error.A;
118+
// ^^^^^^^^^^^^^^ (error{A,B}!S)()
156119

157-
const error_union_22 = if (runtime_bool) error.A else @as(error{B}!i32, 0);
158-
_ = error_union_22;
159-
// ^^^^^^^^^^^^^^ (error{A,B}!i32)()
120+
const error_union_22 = if (runtime_bool) error.A else @as(error{B}!i32, 0);
121+
// ^^^^^^^^^^^^^^ (error{A,B}!i32)()
160122

161-
const error_union_23 = if (runtime_bool) @as(error{B}!i32, 0) else error.A;
162-
_ = error_union_23;
163-
// ^^^^^^^^^^^^^^ (error{A,B}!i32)()
123+
const error_union_23 = if (runtime_bool) @as(error{B}!i32, 0) else error.A;
124+
// ^^^^^^^^^^^^^^ (error{A,B}!i32)()
164125

126+
test "noreturn" {
165127
const noreturn_0 = if (runtime_bool) s else return;
166128
_ = noreturn_0;
167129
// ^^^^^^^^^^ (S)()
168130

169131
const noreturn_1 = if (runtime_bool) return else s;
170132
_ = noreturn_1;
171133
// ^^^^^^^^^^ (S)()
172-
173-
// Use @compileLog to verify the expected type with the compiler:
174-
// @compileLog(error_union_0);
175-
176-
_ = &runtime_bool;
177134
}
178135

179136
const comptime_bool: bool = true;

0 commit comments

Comments
 (0)