authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-18 14:18:00-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-18 18:37:12-07:00
log6018a3ad397ad2104762b1c548866c2c2df2ac77
treefb0aaee97f9ceff48ae31343395592effb61ffb1
parent09ee887e9f08ad1f8124dc57ac3bd2f0df9148b5

add behavior test for empty error set inference

closes #1386 closes #7541

1 files changed, 21 insertions(+), 0 deletions(-)

test/behavior/error.zig+21
......@@ -287,6 +287,27 @@ test "inferred empty error set comptime catch" {
287287 S.foo() catch @compileError("fail");
288288}
289289
290test "error inference with an empty set" {
291 const S = struct {
292 const Struct = struct {
293 pub fn func() (error{})!usize {
294 return 0;
295 }
296 };
297
298 fn AnotherStruct(comptime SubStruct: type) type {
299 return struct {
300 fn anotherFunc() !void {
301 try expect(0 == (try SubStruct.func()));
302 }
303 };
304 }
305 };
306
307 const GeneratedStruct = S.AnotherStruct(S.Struct);
308 try GeneratedStruct.anotherFunc();
309}
310
290311test "error union peer type resolution" {
291312 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
292313 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO