diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-12-18 14:18:00 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-12-18 18:37:12 -0700 |
| commit | 6018a3ad397ad2104762b1c548866c2c2df2ac77 (patch) | |
| tree | fb0aaee97f9ceff48ae31343395592effb61ffb1 /test/behavior/error.zig | |
| parent | 09ee887e9f08ad1f8124dc57ac3bd2f0df9148b5 (diff) | |
| download | zig-6018a3ad397ad2104762b1c548866c2c2df2ac77.tar.gz zig-6018a3ad397ad2104762b1c548866c2c2df2ac77.zip | |
add behavior test for empty error set inference
closes #1386
closes #7541
Diffstat (limited to 'test/behavior/error.zig')
| -rw-r--r-- | test/behavior/error.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig index ae1445dd9e..f5bf6493d8 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -287,6 +287,27 @@ test "inferred empty error set comptime catch" { S.foo() catch @compileError("fail"); } +test "error inference with an empty set" { + const S = struct { + const Struct = struct { + pub fn func() (error{})!usize { + return 0; + } + }; + + fn AnotherStruct(comptime SubStruct: type) type { + return struct { + fn anotherFunc() !void { + try expect(0 == (try SubStruct.func())); + } + }; + } + }; + + const GeneratedStruct = S.AnotherStruct(S.Struct); + try GeneratedStruct.anotherFunc(); +} + test "error union peer type resolution" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
